#include<stdio.h>
#include<map>
#include<set>
#include<iostream>
#include<string>
using namespace std;
map<string, set<int>> m_title,m_author,m_key,m_pub,m_year;
void search(map<string, set<int>> &mp , string &str){
if(mp.find(str)==mp.end())printf("Not Found\n");
else for(set<int>::iterator it=mp[str].begin();it!=mp[str].end();it++){
printf("%07d\n",*it);
}
}
int main(){
int i, n, m, id;
string temp;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&id); getchar();
getline(cin,temp); m_title[temp].insert(id);
getline(cin,temp); m_author[temp].insert(id);
while(cin>>temp){
m_key[temp].insert(id);char c=getchar();///
if(c=='\n')break;
}
getline(cin,temp); m_pub[temp].insert(id);
getline(cin,temp); m_year[temp].insert(id);
}
scanf("%d",&m);
for(i=0;i<m;i++){
scanf("%d: ",&id);
getline(cin,temp);
cout<<id<<": "<<temp<<endl;
if(id==1)search(m_title,temp);
else if(id==2)search(m_author,temp);
else if(id==3)search(m_key,temp);
else if(id==4)search(m_pub,temp);
else if(id==5)search(m_year,temp);
}
return 0;
}
PAT-A1022
最新推荐文章于 2021-09-26 20:01:41 发布