| ||||||||||
| 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 | |||||||||
枚举算法显示“Presentation Error”,请求赐教!#include<stdio.h>
#include<string.h>
char a[4][15],b[4][15];
char p[4][15];
char c;
long n,m,i,j,k,l;
long o[15];
long u[15];
long x,y;
long N;
char ans[2][50]={" is the counterfeit coin and it is light.",
" is the counterfeit coin and it is heavy."};
int main()
{
scanf("%ld",&N);
for(;N>0;N--)
{
memset(o,0,sizeof(o));
for(i=1;i<=3;i++)
{c=getchar();
scanf("%s",a[i]);
c=getchar();
scanf("%s",b[i]);
c=getchar();
scanf("%s",p[i]);
if(p[i][0]=='e')
for(j=0;j<strlen(a[i]);j++)
o[a[i][j]-64]=o[b[i][j]-64]=1;
}
for(k=0;k<=1;k++)
for(i=1;i<=12;i++)
if(!o[i])
{
if(k==0)u[i]=-1;
else u[i]=1;
for(l=1;l<=3;l++)
{
x=y=0;
for(j=0;j<strlen(a[l]);j++)
{x+=u[a[l][j]-64];
y+=u[b[l][j]-64];}
if(!(p[l][0]=='u'&&x>y||
p[l][0]=='e'&&x==y||
p[l][0]=='d'&&x<y))
break;
}
u[i]=0;
if(l>3)
{putchar(i+64);
puts(ans[k]);
putchar(10);
break;}
}
}
return(0);
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator