Code: Select all
//Code Removed After AC!
Moderator: Board moderators
Code: Select all
//Code Removed After AC!
Code: Select all
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
long i,j,k,l,m,n,x,max;
char s[105][105],party[105][105],s1[10001];
scanf("%ld",&n);
x=0;
while(n--)
{
long a[1001]={0};
x++;
scanf("%ld",&m);
if(x!=1)
printf("\n");
getchar();
for(i=0;i<m;i++)
{
gets(s[i]);
gets(party[i]);
}
scanf("%ld",&l);
getchar();
for(i=0;i<l;i++)
{
gets(s1);
for(j=0;j<m;j++)
{
if(!strcmp(s1,s[j]))
{
a[j]++;
break;
}
}
}
max=0;k=0;l=0;
for(i=0;i<m;i++)
{
if(a[i]>max)
{
max=a[i];
l=i;
}
}
for(i=0;i<m;i++)
if(max==a[i])
k++;
if(max==0)
printf("\n");
else if(k>1)
printf("tie");
else
puts(party[l]);
}
return 0;
}
Code: Select all
#include<iostream>
#include<string>
#include<map>
#include<cstdio>
using namespace std;
string s1[32],s2[32];
int main()
{
// freopen("10374in.txt","r",stdin);
int n,m,i,j,res,k,t;
char ch;
string str;
map<string,int>mp;
bool flag,check=false;
cin>>t;
for(i=0;i<t;i++)
{
if(check)cout<<endl;
if(!check)check=true;
mp.clear();
cin>>n;
getchar();
for(j=0;j<n;j++)
{
str="\0";
while(1)
{
ch=getchar();
if(ch=='\n')break;
str+=ch;
}
// cout<<"1"<<str<<endl;
s1[j]=str;
mp[str]++;
str="\0";
while(1)
{
ch=getchar();
if(ch=='\n')break;
str+=ch;
}
// cout<<"2"<<str<<endl;
s2[j]=str;
}
cin>>m;
getchar();
res=-1;
for(j=0;j<m;j++)
{
str="\0";
while(1)
{
ch=getchar();
if(ch=='\n'||ch==EOF)break;
str+=ch;
}
// cout<<"3"<<str<<endl;
if(mp[str]>0)
{
mp[str]++;
if(mp[str]>res)res=mp[str];
}
}
flag=false;
k=0;
for(j=0;j<n;j++)
{
if(mp[s1[j]]==res)k++;
if(k==2){flag=true;break;}
}
if(flag)cout<<"tie"<<endl;
else{
for(j=0;j<n;j++)
if(mp[s1[j]]==res)
{
cout<<s2[j]<<endl;
break;
}
}
}
}
Code: Select all
3
3
Marilyn Manson
Rhinoceros
Jane Doe
Family Coalition
John Smith
independent
6
John Smith
Marilyn Manson
Jane Doe
John Smith
Marilyn Manson
John Smith
3
Marilyn Manson
Rhinoceros
Jane Doe
Family Coalition
John Smith
independent
6
John Smith
Marilyn Manson
Marilyn Manson
Jane Doe
John Smith
Marilyn Manson
3
Marilyn Manson
Rhinoceros
Jane Doe
Family Coalition
John Smith
independent
6
John Smith
Marilyn Manson
Marilyn Manson
John Smith
Marilyn Manson
John Smith
Code: Select all
independent
Rhinoceros
tie
Code: Select all
1
2
Marilyn Manson
Rhinoceros
Jane Doe
Family Coalition
1
asdf
Code: Select all
tie
Code: Select all
#include<iostream>
#include<string>
#include<map>
#include<cstdio>
using namespace std;
string s1[32],s2[32];
int main()
{
// freopen("10374in.txt","r",stdin);
int n,m,i,j,res,k,t;
char ch;
string str;
map<string,int>mp;
bool flag,check=false;
cin>>t;
for(i=0;i<t;i++)
{
if(check)cout<<endl;
if(!check)check=true;
mp.clear();
cin>>n;
getchar();
for(j=0;j<n;j++)
{
str="\0";
while(1)
{
ch=getchar();
if(ch=='\n')break;
str+=ch;
}
// cout<<"1"<<str<<endl;
s1[j]=str;
mp[str]++;
str="\0";
while(1)
{
ch=getchar();
if(ch=='\n')break;
str+=ch;
}
// cout<<"2"<<str<<endl;
s2[j]=str;
}
cin>>m;
getchar();
res=-1;
for(j=0;j<m;j++)
{
str="\0";
while(1)
{
ch=getchar();
if(ch=='\n'||ch==EOF)break;
str+=ch;
}
// cout<<"3"<<str<<endl;
if(mp[str]>0)
{
mp[str]++;
if(mp[str]>res)res=mp[str];
}
}
flag=false;
k=0;
for(j=0;j<n;j++)
{
if(mp[s1[j]]==res)k++;
if(k==2){flag=true;break;}
}
if(res==-1)cout<<"tie"<<endl;
else if(flag)cout<<"tie"<<endl;
else{
for(j=0;j<n;j++)
if(mp[s1[j]]==res)
{
cout<<s2[j]<<endl;
break;
}
}
}
}
Code: Select all
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<algorithm>
#include<limits>
#include<vector>
#include<stack>
#include<string>
#include<deque>
#include<set>
#include<list>
#include<bitset>
#include<ctime>
#include<functional>
#include<numeric>
#include<cfloat>
#include<sstream>
#include<complex>
#include<queue>
#include<cstring>
#include<stdexcept>
#include<utility>
#include<map>
#include<fstream>
#include<iomanip>
#include<cassert>
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
#define inf (1<<30)-1
#define SIZE 100000001
#define pi 3.14159265358979323846
#define even(a) ((a)%2==0)
#define odd(a) ((a)%2==1)
const double E = 2.7182818284590452353602874713527;
using namespace std;
#define eps 1e-14
map<string,string>mp,mp2;
map<string,long>mp1,mp3;
char ch[10000],ch1[10000],st[10000];
int main()
{
char c;
long i,j,num,y,l,mx,test,n,p,len,r;
scanf("%ld",&test);
for(i=0;i<test;i++)
{
if(i>0)
printf("\n");
y=mx=n=p=0;
scanf("%ld",&num);
getchar();
for(j=0;j<num;j++)
{
gets(st);
len=strlen(st);
for(r=0;r<len;r++)
{
if(st[r]!=' ')
{
ch[p]=st[r];
p++;
}
}
ch[p]=NULL;
p=0;
gets(st);
len=strlen(st);
for(r=0;r<len;r++)
{
if(st[r]!=' ')
{
ch1[p]=st[r];
p++;
}
}
ch1[p]=NULL;
p=0;
mp[ch]=ch1;
mp3[ch]=1;
}
scanf("%ld",&num);
getchar();
p=0;
for(j=0;j<num;j++)
{
gets(st);
len=strlen(st);
for(r=0;r<len;r++)
{
if(st[r]!=' ')
{
ch[p]=st[r];
p++;
}
}
ch[p]=NULL;
p=0;
if(mp3[ch]!=0)
{
n=1;
l=++mp1[mp[ch]];
if(l>=mx)
{
if(l!=mx)
{
y=1;
mp2["res"]=mp[ch];
mx=l;
}
else
{
y=0;
}
}
}
}
if(y==0||n==0)
{
printf("tie\n");
}
else
cout<<mp2["res"]<<endl;
mp.clear(),mp1.clear(),mp2.clear(),mp3.clear();
}
return 0;
}
Code: Select all
AC