-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1620.cpp
42 lines (35 loc) · 801 Bytes
/
1620.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
int main(){
int n, m;
map<int, string> findByNum;
map<string, int> findByName;
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++){
char str[21];
scanf("%s",str);
string temp=str;
findByNum.insert(make_pair(i,temp));
findByName.insert(make_pair(temp, i));
}
for(int i=0;i<m;i++){
char temp[21];
scanf("%s",temp);
if(temp[0]>='0' && temp[0]<='9'){
int key=atoi(temp);
std::map<int, string>::iterator it=findByNum.find(key);
// iterator°¡ Á¤È®È÷ ¹¹Â¡..
string print=it->second;
printf("%s\n",print.c_str());
}
else{
string skey=temp;
std::map<string, int>::iterator it=findByName.find(skey);
printf("%d\n",it->second);
}
}
}