-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10152.cpp
More file actions
56 lines (53 loc) · 1021 Bytes
/
10152.cpp
File metadata and controls
56 lines (53 loc) · 1021 Bytes
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
#include <iostream>
#include <map>
#include <list>
#include <string>
using namespace std;
typedef list<string> List;
typedef List::iterator It;
typedef map<string,string*> Map;
typedef List::reverse_iterator RIt;
int main(){
List orig, dest;
Map index;
string buffer;
int kase;
cin>>kase;
for(int i=0;i<kase;i++){
int n;
cin>>n;
getline(cin,buffer);
for(int i=0;i<n;i++){
getline(cin,buffer);
orig.push_back(buffer);
index.insert(make_pair(buffer,&(orig.back())));
}
for(int i=0;i<n;i++){
getline(cin,buffer);
dest.push_back(buffer);
}
It it,oit;
it=dest.begin();
oit=orig.begin();
while(it!=dest.end()){
It dit=it;
bool match=true;
while(dit!=dest.end()){
while(*oit=="*") ++oit;
if(*dit!=*oit) {match=false; break;}
++dit; ++oit;
}
if(match) break;
*(index[*dit])="*";
it=dit; ++it;
}
for(RIt rit=RIt(it);rit!=dest.rend();++rit){
cout<<(*rit)<<endl;
}
cout<<endl;
orig.clear();
dest.clear();
index.clear();
}
return 0;
}