본문 바로가기

성우리뷰

나는야포켓몬마스타-

#include <iostream>
#include <string>
#include <cstdio>
#include <stdlib.h>
#include <map>

using namespace std;

map<string, int> arr;
string list[100001];

int main(void)
{
int x, y;
cin >> x;
cin >> y;

char name[21];
for (int i = 1; i <= x; i++)
{
scanf_s("%s", name, sizeof(name));
string str = name;

arr.insert(pair<string, int>(str, i));
list[i] = str;
}

for (int i = 1; i <= y; i++)
{
char name[21];
scanf_s("%s", name, sizeof(name));

if (isdigit(name[0]))
{
cout << list[atoi(name)];
cout << "\n";
}
else
{
string str = name;
printf("%d\n", arr[str]);
}
}
return 0;
}

 

모리노나카히노나카미즈노나카소라노나카

'성우리뷰' 카테고리의 다른 글

동적계획) 가장긴수열  (5) 2020.08.04
연산자 끼워넣기  (2) 2020.08.04
18115)카드 스택  (2) 2020.07.24
1260)dfs bfs  (2) 2020.07.22
2328)임시)런타임에러뜸)그래프의 해시  (2) 2020.07.21