Algorithm/백준
C++ 알고리즘 - 백준 1620 나는야 포켓몬 마스터 이다솜 (unordered_map)
마루설아
2025. 1. 4. 18:30
https://www.acmicpc.net/problem/1620
#include <bits/stdc++.h>
#include <unordered_map>
#define endl "\n"
using namespace std;
int main(void) {
// C++ Init
ios::sync_with_stdio(false);
cin.tie(NULL);
int input1, input2;
string str;
unordered_map<string, int> um;
vector<string> v;
cin >> input1 >> input2;
for (int i = 0; i < input1; i++) {
cin >> str;
um.insert({ str, i + 1 });
v.push_back(str);
}
for (int i = 0; i < input2; i++) {
cin >> str;
if (isdigit(str[0])) {
cout << v[stoi(str) - 1] << endl;
}
else cout << um[str] << endl;
}
}