728x90
반응형
https://www.acmicpc.net/problem/16165
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n, m, mn, q;
string group, member, name;
vector<pair<string, string>> v;
cin >> n >> m;
for(int i = 0; i < n; i++){
cin >> group >> mn;
for(int j = 0; j < mn; j++){
cin >> member;
v.push_back({group, member});
}
}
sort(v.begin(), v.end());
for(int i = 0; i < m; i++){
cin >> name >> q;
if(q == 0){
for(int j = 0; j < v.size(); j++){
if(v[j].first == name) {
cout << v[j].second << endl;
}
}
} else{
for(int j = 0; j < v.size(); j++){
if(v[j].second == name) {
cout << v[j].first << endl;
break;
}
}
}
}
return 0;
}
728x90
반응형
'Algorithm > BAEKJOON' 카테고리의 다른 글
[BOJ] 24479번, 24480번 알고리즘 수업 - 깊이 우선 탐색 1, 2 (C++) (0) | 2022.02.15 |
---|---|
[BOJ] 15989번 1, 2, 3 더하기 4 (C++) (0) | 2022.02.14 |
[BOJ] 3495번 아스키 도형 (C++) (0) | 2022.02.13 |
[BOJ] 21966번 (중략) (C++) (0) | 2022.02.13 |
[BOJ] 1461번 도서관 (C++) (0) | 2022.02.13 |