구현 아이디어 5분
구현 15분
endl -> 'n\'.
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <unordered_map>
using namespace std;
int main() {
//freopen("input.txt", "rt", stdin);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N{}, M{};
cin >> N >> M;
string PocketmonName{};
unordered_map<string, int> MapPocketmons;
vector<string> VecPocketmons(N + 1);
for (int ix = 1; ix <= N; ++ix)
{
cin >> PocketmonName;
MapPocketmons.insert(make_pair(PocketmonName, ix));
VecPocketmons[ix] = PocketmonName;
}
string Question;
for (int ix = 0; ix < M; ++ix)
{
cin >> Question;
if (Question[0] >= '0' && Question[0] <= '9')
{
cout << VecPocketmons[stoi(Question)] << '\n';
}
else
{
cout << MapPocketmons[Question] << '\n';
}
}
return 0;
}