-
Notifications
You must be signed in to change notification settings - Fork 0
/
UVA 10374.cpp
58 lines (58 loc) · 1.29 KB
/
UVA 10374.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
#include<stdio.h>
#include<string.h>
int main()
{
char c[50][100],d[50][100],s[100];
int i,l,n,j,t,m,frequency[100]= {0},maxx,k,maximum;
scanf("%d",&t);
for(i=0; i<t; i++)
{
int flag=0;
for(j=0;j<100;j++)
{
frequency[j]=0;
}
maxx=0;
maximum=0;
scanf("%d",&n);
while(getchar()!='\n');
for(j=0; j<n; j++)
{
gets(c[j]);
gets(d[j]);
}
scanf("%d",&m);
while(getchar()!='\n');
for(j=0; j<m; j++)
{
gets(s);
for(k=0; k<n; k++)
{
if(strcmp(s,c[k])==0)
{
frequency[k]++;
if(frequency[k]>maximum)
{
maxx=k;
maximum=frequency[k];
}
break;
}
}
}
for(j=0;j<n;j++)
{
if(frequency[j]==maximum)
{
flag++;
}
}
if(flag>1)
printf("tie\n");
else
printf("%s\n",d[maxx]);
if(i!=t-1)
printf("\n");
}
return 0;
}