-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1022.cpp
More file actions
45 lines (43 loc) · 1.06 KB
/
1022.cpp
File metadata and controls
45 lines (43 loc) · 1.06 KB
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
43
44
45
#include <iostream>
#include <set>
#include <map>
using namespace std;
map<string, set<int>> maps[6];
int main() {
int n, m;
cin >> n;
while (n--) {
int id;
string title, author, key, publisher, year;
cin >> id; getchar(); // skip '\n'
getline(cin, title);
maps[1][title].insert(id);
getline(cin, author);
maps[2][author].insert(id);
while (true) {
char c;
cin >> key;
maps[3][key].insert(id);
if ((c = getchar()) == '\n') break;
}
getline(cin, publisher);
maps[4][publisher].insert(id);
getline(cin, year);
maps[5][year].insert(id);
}
cin >> m;
while (m--) {
int type;
string key;
scanf("%d: ", &type);
getline(cin, key);
printf("%d: %s\n", type, key.c_str());
if (maps[type][key].empty()) {
printf("Not Found\n");
continue;
}
for (auto id : maps[type][key])
printf("%07d\n", id);
}
return 0;
}