Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我是真不服气 找得原始数据都过了 怎么会WA#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int main() { //freopen("input.txt", "r", stdin); int i,j,len,n,d[12],temp[12]; char left[12],right[12],cmp[4]; scanf("%d",&n); while(n--) { memset(d,0,sizeof(d)); for(i=0;i<3;i++) { scanf("%s%s%s",left,right,cmp); len=strlen(left); if(cmp[0]=='e') { for(j=0;j<len;j++) { d[left[j]-'A']=1; d[right[j]-'A']=1; } } else if(cmp[0]=='u') { memset(temp,0,sizeof(temp)); for(j=0;j<len;j++) { if(d[left[j]-'A']==-1) d[left[j]-'A']=1; else if(d[left[j]-'A']==0) d[left[j]-'A']=2; if(d[right[j]-'A']==2) d[right[j]-'A']=1; else if(d[right[j]-'A']==0) d[right[j]-'A']=-1; temp[left[j]-'A']=1; temp[right[j]-'A']=1; } for(j=0;j<12;j++) if(temp[j]==0) d[j]=1; } else if(cmp[0]=='d') { memset(temp,0,sizeof(temp)); for(j=0;j<len;j++) { if(d[left[j]-'A']==2) d[left[j]-'A']=1; else if(d[left[j]-'A']==0) d[left[j]-'A']=-1; if(d[right[j]-'A']==-1) d[right[j]-'A']=1; else if(d[right[j]-'A']==0) d[right[j]-'A']=2; temp[left[j]-'A']=1; temp[right[j]-'A']=1; } for(j=0;j<12;j++) if(temp[j]==0) d[j]=1; } } for(i=0;i<12;i++) { if(d[i]==-1) printf("%c is the counterfeit coin and it is light.\n",i+'A'); if(d[i]==2) printf("%c is the counterfeit coin and it is heavy.\n",i+'A'); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator