#12736:


clktease (unknown)

學校 : 國立中山大學
編號 : 66330
來源 : [118.232.108.196]
最後登入時間 :
2024-02-05 19:18:13
b999. NOIP2016 Day2.3.愤怒的小鸟 -- NOIP2016提高组Day2第三题 | From: [140.117.183.68] | 發表日期 : 2017-09-22 11:54

#include <iostream>
#include <string>
#include <cmath>
#include<string.h>
#include<map>
using namespace std;


int main()
{
int n;
while(cin >> n)
{getchar();

while(n--)
{int f[12]={0};

for(int p=0;p<3;p++)
{string s;
int flag=0,flag1=0;
getline (cin, s);
for(int i=0;i<s.size();i++)
{if(s[i]=='e')
{flag=1;break;}
if(s[i]=='u')
{flag1=1;break;}
if(s[i]=='d')
break;
}
if(flag==1)
{
for(int i=0;i<s.size();i++)
if(s[i]>='A'&&s[i]<='Z')
f[s[i]-'A']=-1;
}
if(flag1==1)
{int k;
for( k=0;s[k]!=' ';k++)
{ if(s[k]>='A'&&s[k]<='Z')
{switch(f[s[k]-'A'])
{case 0:
f[s[k]-'A']=1;
break;
case 1:
f[s[k]-'A']=3;
break;
case 2:
f[s[k]-'A']=-1;
break;
}
}
}
for(k=k+1;k!=' ';k++)
{if(s[k]>='A'&&s[k]<='Z')
{switch(f[s[k]-'A'])
{case 0:
f[s[k]-'A']=2;
break;
case 2:
f[s[k]-'A']=4;
break;
case 1:
f[s[k]-'A']=-1;
break;
}
}
}
}
if(flag==0&&flag1==0)
{int o;
for(o=0;s[o]!=' ';o++)
{if(s[o]>='A'&&s[o]<='Z')
{switch(f[s[o]-'A'])
{case 0:
f[s[o]-'A']=2;
break;
case 2:
f[s[o]-'A']=4;
break;
case 1:
f[s[o]-'A']=-1;
break;
}
}
}
for( o=o+1;s[o]!=' ';o++)
{ if(s[o]>='A'&&s[o]<='Z')
{switch(f[s[o]-'A'])
{case 0:
f[s[o]-'A']=1;
break;
case 1:
f[s[o]-'A']=3;
break;
case 2:
f[s[o]-'A']=-1;
break;
}
}
}
}
}

int check=0;
for(int i=0;i<12;i++)
{if(f[i]==3)
{check=1;
cout <<char(i+'A')<<" is the counterfeit coin and it is "<<"heavy."<<endl;}
if(f[i]==4)
{check=1;
cout <<char(i+'A')<<" is the counterfeit coin and it is "<<"light."<<endl;
}
}

if(check==0)
for(int i=0;i<12;i++)
{if(f[i]==1)

cout <<char(i+'A')<<" is the counterfeit coin and it is "<<"heavy."<<endl;
if(f[i]==2)
cout <<char(i+'A')<<" is the counterfeit coin and it is "<<"light."<<endl;

}

}

 

 

}

return 0;
}

 
ZeroJudge Forum