File tree 4 files changed +65
-0
lines changed 4 files changed +65
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ int N, M;
5
+ unordered_map<string, int > name2num;
6
+ string num2name[100'002 ];
7
+
8
+ int main () {
9
+ ios::sync_with_stdio (false );
10
+ cin.tie (NULL );
11
+
12
+ cin >> N >> M;
13
+ for (int i = 1 ; i <= N; i++) {
14
+ cin >> num2name[i];
15
+ name2num[num2name[i]] = i;
16
+ }
17
+
18
+ for (int i = 1 ; i <= M; i++) {
19
+ string input;
20
+ cin >> input;
21
+ int is_digit = int (input[0 ]) - int (' 0' );
22
+ if (is_digit >= 0 && is_digit <= 9 ) {
23
+ int num = 0 ;
24
+ for (int j = 0 ; j < input.length (); j++) {
25
+ num *= 10 ;
26
+ num += int (input[j]) - int (' 0' );
27
+ }
28
+ cout << num2name[num];
29
+ } else
30
+ cout << name2num[input];
31
+ cout << " \n " ;
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ 26 5
2
+ Bulbasaur
3
+ Ivysaur
4
+ Venusaur
5
+ Charmander
6
+ Charmeleon
7
+ Charizard
8
+ Squirtle
9
+ Wartortle
10
+ Blastoise
11
+ Caterpie
12
+ Metapod
13
+ Butterfree
14
+ Weedle
15
+ Kakuna
16
+ Beedrill
17
+ Pidgey
18
+ Pidgeotto
19
+ Pidgeot
20
+ Rattata
21
+ Raticate
22
+ Spearow
23
+ Fearow
24
+ Ekans
25
+ Arbok
26
+ Pikachu
27
+ Raichu
28
+ 25
29
+ Raichu
30
+ 3
31
+ Pidgey
32
+ Kakuna
You can’t perform that action at this time.
0 commit comments