-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10374 you can use gets().cpp
63 lines (61 loc) · 1.49 KB
/
10374 you can use gets().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
63
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<stack>
using namespace std;
int i,cases,n,b,j,res,g;
char A[300],B[300];
int main(){
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
scanf("%d\n",&cases);
while(cases--){
//string b="independent";
map<string,string>m;
vector<string>x;
scanf("%d\n",&n);
while(n--){
gets(A);
gets(B);
//getchar();
m[A]=B;
x.push_back(A);
}
//for(i=0;i<x.size();i++){
//cout<<x[i]<<" "<<m[x[i]]<<endl;
//}
scanf("%d\n",&g);
map<string,int>v;
while(g--){
gets(A);
v[A]++;
//cout<<A<<" "<<v[A]<<endl;
}
int high=-1,res;
for(i=0;i<x.size();i++){
if(v[x[i]]>high){
//printf("dhuke nai\n");
high=v[x[i]];
res=i;
}
}
int eta=0;
for(i=0;i<x.size();i++){
if(v[x[i]]==high && v[x[i]]!=0){
//cout<<x[i]<<endl;
//printf("dhuke nai\n");
eta++;
if(eta>=2)break;
}
}
if(eta>=2 || high==0)printf("tie\n");
else{
cout<<m[x[res]]<<endl;
}
if(cases)printf("\n");
}
}