-
Notifications
You must be signed in to change notification settings - Fork 0
/
pat 1022(2).cpp
62 lines (60 loc) · 1.85 KB
/
pat 1022(2).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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include <set>
#include <map>
#include <iomanip>
#include <string>
using namespace std;
map<string,set<int>> tag[5];//title,author,key,pub,year
int N,M;
int main()
{
int i,j;
string tmp_s;
cin >> N;
for( i = 0; i < N ; i++)
{
int tmp_i;
map<string,set<int>>::const_iterator pos;
cin >> tmp_i;
cin.get();
for(j = 0 ; j < 5 ; j++)
{
if(j == 2)
{
for(;;)
{
cin >> tmp_s;
tag[j][tmp_s].insert(tmp_i);
if( getchar() == '\n')
break;
}
}
else
{
getline(cin,tmp_s);
tag[j][tmp_s].insert(tmp_i);
}
}
}
cin >> M;
int choose;
map<string,set<int>>::const_iterator pos;
set<int>::const_iterator poset;
for( i = 0 ; i < M ; i++)
{
cin >> choose;
cin.ignore(2);
getline(cin,tmp_s);
cout<< choose << ": " << tmp_s <<endl;
pos = tag[choose-1].find(tmp_s);
if( pos == tag[choose-1].end() )
{
cout<<"Not Found"<<endl;
}
else
{
for(poset = pos->second.begin() ; poset != pos->second.end() ; poset++)
cout<< setw(7) << setfill('0') <<*poset<<endl;
}
}
}