#PTA#1022 Digital Library

34一直过不去,搜了别人的发现是没写07d.......

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

map<string,vector<int> > mp[5];//0:title 1:author  2:key word  3:publisher  4:year

int n,m;
int main(){
	scanf("%d",&n);
	
	int id=0;
	string s="";
	for(int i=0;i<n;i++){
		scanf("%d",&id);
		
		getchar();
		getline(cin,s);
		mp[0][s].push_back(id);
		
		getline(cin,s);
		mp[1][s].push_back(id);
		
		//cout<<"s:"<<s<<endl;
		
		char c;
		string sp="";
		while((c=getchar())!='\n'){
			//cout<<"key:"<<key<<endl;
			if(c==' '){
				mp[2][sp].push_back(id);
				//cout<<"sp:"<<sp<<",";
				sp="";
			}else{
				sp+=c;
			}			
		}
		mp[2][sp].push_back(id);//最后一个啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
		
		
		
		getline(cin,s);
		mp[3][s].push_back(id);
		
		//cout<<"s:"<<s<<endl; 

		getline(cin,s);
		mp[4][s].push_back(id);
		
	}
	
	scanf("%d",&m);
	
	//cout<<"m:"<<m<<endl;
	
	int x=0;
	string query="";
	for(int i=0;i<m;i++){
		scanf("%d:",&x);
		getchar();
		getline(cin,query);
		
				
		printf("%d: %s\n",x,query.c_str());
		if(mp[x-1][query].size()==0){
			printf("Not Found\n");
			continue;
		}
		
		sort(mp[x-1][query].begin(),mp[x-1][query].end());
		for(int j=0;j<mp[x-1][query].size();j++){
			printf("%07d\n",mp[x-1][query][j]);
		}		
	}	
	return 0;
}

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值