#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string.h>
#include<set>
#include<stdio.h>
#define REP(i,n) for(i=0;i<n;i++)
using namespace std;
int main()
{
long cs,tst,i,n;
scanf("%ld",&cs);
REP(tst,cs)
{
map<string,long>v;
map<string,long>::iterator it;
long ar[30]= {0},vote,flag=0,k=0;
char man[30][90]= {0},party[30][90]= {0},ballot[900]= {0};
scanf("%ld\n",&n);
REP(i,n)
{
gets(man[i]);
gets(party[i]);
v[man[i]]=1;
}
scanf("%ld\n",&vote);
REP(i,vote)
{
gets(ballot);
if(v[ballot]>=1)
v[ballot]++;
}
REP(i,n)
ar[i]=v[man[i]];
sort(ar,ar+n);
if(tst!=0)
printf("\n");
REP(i,n)
{
if(ar[n-1]==v[man[i]])
flag++;
}
if(flag==0||flag>1)
cout<<"tie\n";
else
{
REP(i,n)
{
if(ar[n-1]==v[man[i]])
{
printf("%s\n",party[i]);
break;
}
}
}
}
return 0;
}
#include<vector>
#include<algorithm>
#include<map>
#include<string.h>
#include<set>
#include<stdio.h>
#define REP(i,n) for(i=0;i<n;i++)
using namespace std;
int main()
{
long cs,tst,i,n;
scanf("%ld",&cs);
REP(tst,cs)
{
map<string,long>v;
map<string,long>::iterator it;
long ar[30]= {0},vote,flag=0,k=0;
char man[30][90]= {0},party[30][90]= {0},ballot[900]= {0};
scanf("%ld\n",&n);
REP(i,n)
{
gets(man[i]);
gets(party[i]);
v[man[i]]=1;
}
scanf("%ld\n",&vote);
REP(i,vote)
{
gets(ballot);
if(v[ballot]>=1)
v[ballot]++;
}
REP(i,n)
ar[i]=v[man[i]];
sort(ar,ar+n);
if(tst!=0)
printf("\n");
REP(i,n)
{
if(ar[n-1]==v[man[i]])
flag++;
}
if(flag==0||flag>1)
cout<<"tie\n";
else
{
REP(i,n)
{
if(ar[n-1]==v[man[i]])
{
printf("%s\n",party[i]);
break;
}
}
}
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন