알고리즘
백준 1380번 귀걸이 C++
영춘권의달인
2022. 4. 25. 10:35
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
using namespace std;
using ll = long long;
int dRow[4] = { -1,0,1,0 };
int dCol[4] = { 0,1,0,-1 };
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int cnt = 1;
while (true) {
int n;
cin >> n;
if (n == 0) break;
vector<string> v(n + 1);
map<string, int> mp;
cin.ignore();
for (int i = 1; i <= n; i++) {
getline(cin, v[i]);
}
for (int i = 0; i < 2 * n - 1; i++) {
int num;
char c;
cin >> num >> c;
mp[v[num]]++;
}
string name = "";
for (auto a : mp) {
if (a.second == 1)
name = a.first;
}
cout << cnt << " " << name << "\n";
cnt++;
}
};