#include <cstdio>
#include <cmath>
#include <cstring>
#define _abs(x) (x>=0? x:(-x))
int main()
{
char left[6],right[6],bal[6];
int nCase;
scanf("%d",&nCase);
int i;
for(i=1;i<=nCase;++i)
{
int ii=3,j;
int flag;
int a[13];
int b[13];
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
while(ii--){
scanf("%s %s %s",left,right,bal);
if(strcmp(bal,"even")==0)
{
int k;
for(k=0;left[k];++k)
{
a[(left[k]-65)]=1;
a[(right[k]-65)]=1;
}
}
else
if(strcmp(bal,"up")==0)
{
int k;
for(k=0;k<left[k];++k)
{
b[(left[k]-65)]++;
b[(right[k]-65)]--;
}
}
else
{
int k;
for(k=0;left[k];++k)
{
b[(left[k]-65)]--;
b[(right[k]-65)]++;
}
}
}
int max=-1;
int index;
for(j=0;j<13;++j)
{
if(a[j])
continue;
if(_abs(b[j])>max)
{
max=_abs(b[j]);
index=j;
}
}
if(b[index]<=0)
printf("%c is the counterfeit coin and it is light.\n",char(index+65));
else
printf("%c is the counterfeit coin and it is heavy.\n",char(index+65));
}
}
POJ 1013
最新推荐文章于 2020-01-07 17:19:09 发布