Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 호스트 주소
- BFS
- OSI 3계층
- 서브넷
- List 정렬
- list 사용법
- 백준
- Visual Studio
- 알고리즘
- c#
- InsertRange
- Tostring 사용법
- IP주소
- List 찾기
- Parse 사용법
- list
- 기본 게이트웨이
- c# list
- DP
- 호스트
- 서브넷 마스크
- 네트워크
- 네트워크 용어
- TCP/IP
- AddRange
- List 제거
- C# Contains
- List 추가
- C++
- C# Find
Archives
- Today
- Total
CodeLabs
[백준 / C++] 1764 : 듣보잡 본문
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define pp pair<int,string>
using namespace std;
int n, m, idx = 0;
string str;
map<string, bool> mm;
map<int, string> answer;
bool compare(const pp& a, const pp& b)
{
if (a.second == b.second)
return a.first < b.first;
return a.second < b.second;
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> str;
mm[str] = true;
}
for (int i = 0; i < m; i++)
{
cin >> str;
if (mm[str])
{
answer[idx] = str;
idx++;
}
}
vector<pp> vec(answer.begin(), answer.end());
vector<pp>::iterator iter;
sort(vec.begin(), vec.end(), compare);
cout << answer.size() << endl;
for (iter = vec.begin(); iter != vec.end(); iter++)
cout << iter->second << endl;
}
'백준 > 1000 ~' 카테고리의 다른 글
[백준 / C#] 1931 : 회의실 배정 (0) | 2023.07.26 |
---|---|
[백준 / C#] 1927 : 최소 힙 (0) | 2023.07.24 |
[백준 / C#] 1697 : 숨바꼭질 (0) | 2023.07.18 |
[백준 / C++] 1620 : 나는야 포켓몬 마스터 이다솜 (0) | 2023.07.15 |
[백준 / C#] 1541 : 잃어버린 괄호 (0) | 2023.07.13 |