#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char Left[3][10],Right[3][10],result[3][10];
bool fake(char c,bool light)
{
for(int i=0;i<3;i++)
{
char *pleft=Left[i],*pright=Right[i];
if(!light) swap(pleft,pright);
switch (result[i][0])
{
case 'u':
if(!strchr(pright,c))
return false;
break;
case 'e':
if(strchr(pright,c)||strchr(pleft,c))
return false;
break;
case 'd':
if(!strchr(pleft,c))
return false;
break;
}
}
return true;
}
int main()
{
int k;cin>>k;
while(k--)
{
for(int i=0;i<3;i++) cin>>Left[i]>>Right[i]>>result[i];
for(char c='A';c<='L';c++)
{
if(fake(c,true))
{
printf("%c is the counterfeit coin and it is light.\n",c);
break;
}
else if(fake(c,false))
{
printf("%c is the counterfeit coin and it is heavy.\n",c);
break;
}
}
}
}
poj:1013偽造ドル
おすすめ
転載: blog.csdn.net/weixin_49640089/article/details/114378620
ランキング