-
Notifications
You must be signed in to change notification settings - Fork 814
/
Copy path1022. Digital Library (30) .cpp
46 lines (46 loc) · 1.3 KB
/
1022. Digital Library (30) .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
43
44
45
46
#include <iostream>
#include <map>
#include <set>
using namespace std;
map<string, set<int> > title, author, key, pub, year;
void query(map<string, set<int> > &m, string &str) {
if(m.find(str) != m.end()) {
for(auto it = m[str].begin(); it != m[str].end(); it++)
printf("%07d\n", *it);
} else
cout << "Not Found\n";
}
int main() {
int n, m, id, num;
scanf("%d", &n);
string ttitle, tauthor, tkey, tpub, tyear;
for(int i = 0; i < n; i++) {
scanf("%d\n", &id);
getline(cin, ttitle);
title[ttitle].insert(id);
getline(cin, tauthor);
author[tauthor].insert(id);
while(cin >> tkey) {
key[tkey].insert(id);
char c = getchar();
if(c == '\n') break;
}
getline(cin, tpub);
pub[tpub].insert(id);
getline(cin, tyear);
year[tyear].insert(id);
}
scanf("%d", &m);
for(int i = 0; i < m; i++) {
scanf("%d: ", &num);
string temp;
getline(cin, temp);
cout << num << ": " << temp << "\n";
if(num == 1) query(title, temp);
else if(num == 2) query(author, temp);
else if(num == 3) query(key, temp);
else if(num == 4) query(pub,temp);
else if(num ==5) query(year, temp);
}
return 0;
}