| ||||||||||
| 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 | |||||||||
连变态输入都考虑了还是不能通过……能给出错误的数据点吗?In Reply To:我觉得这道题的思路比较清晰啊 为什么总是WA呢?实在是想不出什么疏漏了……请高手指点 Posted by:phantomr at 2005-04-27 17:19:25 #include<stdio.h>
#include<string.h>
main()
{
char left[20],right[20],result[5],input[3][12],fact[12];
int i,j,t;
scanf("%d",&t); //the number of cases
for(;t>0;t--)
{
for(i=0;i<3;i++)
for(j=0;j<12;j++)
input[i][j]='?';
for(j=0;j<3;j++)
{
scanf("%s %s %s",left,right,result);//input condition
if(strcmp(result,"even")==0)
{for(i=0;i<12;i++)
input[j][i]='?'; //can be all the possibilities
for(i=0;left[i]!='\0';i++)
{input[j][left[i]-65]=(input[j][left[i]-65]==0)? '?':0; //real
input[j][right[i]-65]=(input[j][right[i]-65]==0)? '?':0;}
}
else
{for(i=0;i<12;i++)
input[j][i]=0;
if(strcmp(result,"up")==0)
for(i=0;left[i]!='\0';i++)
{input[j][left[i]-65]=(input[j][left[i]-65]==-1)? 0:1; //possibly heavy
input[j][right[i]-65]=(input[j][right[i]-65]==1)? 0:-1;} //possibly light
else
for(i=0;left[i]!='\0';i++)
{input[j][left[i]-65]=(input[j][left[i]-65]==1)? 0:-1; //'A'-65=0
input[j][right[i]-65]=(input[j][right[i]-65]==-1)? 0:1;}
}
}
for(i=0;i<12;i++)
{if(input[0][i]==0||input[1][i]==0||input[2][i]==0)
continue;
else
if(input[0][i]==1||input[1][i]==1||input[2][i]==1)
{strcpy(fact,"heavy");
break;}
else
{strcpy(fact,"light");
break;}
}
printf("%c is the counterfeit coin and it is %s.\n",i+65,fact);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator