#include <iostream>
#include <sstream>
#include <cstdio>
#include <map>
#include <set>
#include <cstring>
using namespace std;
int main(int argc, char **argv) {
int n;
cin >> n;
map<string, set<string> > index[5];
char line[100];
string id;
for(int i = 0; i < n; i ++) {
cin >> id;
gets(line);
for(int j = 0; j < 5; j ++) {
gets(line);
if(j != 2) {
index[j][line].insert(id);
}
else {
string keyword;
istringstream is(line);
while(is >> keyword) {
index[j][keyword].insert(id);
}
}
}
}
int m;
cin >> m;
int c;
for(int i = 0; i < m; i ++) {
scanf("%d: ", &c);
gets(line);
printf("%d: %s\n", c, line);
map<string, set<string> >::iterator it = index[c-1].find(line);
if(it != index[c-1].end()) {
set<string> &books = it->second;
for(set<string>::iterator bit = books.begin(); bit != books.end(); bit ++) {
cout << *bit << endl;
}
}
else {
cout << "Not Found" << endl;
}
}
return 0;
}
1022. Digital Library (30)
最新推荐文章于 2018-07-19 15:52:46 发布