1764 듣보잡


1. 듣도 못한 사람을 map<string, int> m 에 넣는다.


2. 보도 못한 사람이면서 듣도 못한 사람을 string 벡터 v에 넣는다.


3. 정렬한 후 출력한다.


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
32
33
34
35
36
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false);
    map<stringint> m;
    vector<string> v;
 
    int a, b;
    cin >> a >> b;
 
    while (a--) {
        string str;
        cin >> str;
        m.emplace(str, 1);
    }
 
    while (b--) {
        string str;
        cin >> str;
        if (m.count(str)) {
            v.push_back(str);
        }
    }
 
    sort(v.begin(), v.end());
    cout << v.size() << "\n";
    for (auto ss : v) {
        cout << ss << "\n";
    }
 
}
cs


'BOJ::문제풀이' 카테고리의 다른 글

5427 불  (0) 2018.02.27
2294 동전 2  (0) 2018.02.27
9663 N-Queen  (0) 2018.02.24
1949 우수마을  (1) 2018.02.23
3190 뱀  (1) 2018.02.21

+ Recent posts