Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

救命啊!!! 讨论区里面的数据都测试过了,没有错啊,怎么老是WA??? 同志们! 谁帮我找一下原因啊???

Posted by guying at 2008-04-20 03:47:05 on Problem 1013
#include<iostream>
using namespace std;
int main()
{
	int i, j, n, c[3], b[13]={0}, e[13], k, t, m[3], p;
	char a[3][20], d[13]={' ','A','B','C','D','E','F','G','H','I','J','K','L'};
	cin>>n;
	p=n;
	gets(a[0]);
	while(n&&p)
	{
	   
		p--;
		for(i=0; i<13; i++)
		{
			e[i]=0;
			b[i]=0;
		}
		n--;
		for(i=0; i<3; i++)
		{
			gets(a[i]);
		}
		for(i=0; i<3; i++)
			for(j=4; j<20; j++)
			{
				if(a[i][j]=='u')   { c[i]=1;  break; }
				if(a[i][j]=='v')   { c[i]=0;  break; }
				if(a[i][j]=='o')   { c[i]=-1;  break; }
			}
		if(c[0]==c[1]&&c[1]==c[2]&&(c[2]==1||c[2]==-1))
		{    
			for(k=1; k<13;  k++)
			{    
				 t=0;
			     for(i=0;i<3;i++)
				 {
			        for(j=0; ;j++)
					{
				        if(a[i][j]==' ')  break;
						if(a[i][j]==d[k]) {  t++;  break; }
					}
				 }
				 if(t==3&&c[0]==1)   { cout<<d[k]<<" is the counterfeit coin and it is heavy."<<endl;  break; }
				 if(t==3&&c[0]==-1)   { cout<<d[k]<<" is the counterfeit coin and it is light."<<endl;  break; }
			}
			for(k=0; k<3; k++)
				for(j=0; ; j++)
					if(a[k][j]==' ')   {  m[k]=j+1; break; }
           
            for(k=1; k<13&&t!=3;  k++)
			{    
				 t=0;
                 for(i=0;i<3;i++)
				 {
			        for(j=m[i]; ;j++)
					{
				        if(a[i][j]==' ')  break;
						if(a[i][j]==d[k]) {  t++;  break; }
					}
				 }
                 if(t==3&&c[0]==1)   { cout<<d[k]<<" is the counterfeit coin and it is light."<<endl;  break; }
				 if(t==3&&c[0]==-1)   { cout<<d[k]<<" is the counterfeit coin and it is heavy."<<endl;  break; }
			}
		}
		else
		{			 
		    for(i=0; i<3; i++ )
			{		
			    if(c[i]==1)
				{
				    for(j=0; ;j++)
					{
					    if(a[i][j]==' ')    break;
					    t=a[i][j]-'0'-16;
			            if(b[t]==-2||b[t]>0)  b[t]=t;
					    else b[t]=-1;   //overweight
					}
				    for(j=j+1; ;j++)
					{
					    if(a[i][j]==' ')   break;
					    t=a[i][j]-'0'-16;
					    if(b[t]==-1||b[t]>0)  b[t]=t;
					    else b[t]=-2;  //overlight
					}
				}
			}
		    for(i=0; i<3; i++)
			{
			    if(c[i]==-1)
				{
                    for(j=0; ;j++)
					{
					    if(a[i][j]==' ')    break;
					    t=a[i][j]-'0'-16;
					    if(b[t]==-2)   e[t]=t;  
					    if(b[t]==-1||b[t]>0)    b[t]=t;
					    b[t]=-2;   
					}
                    for(j=j+1; ;j++)
					{
					    if(a[i][j]==' ')   break;
					    t=a[i][j]-'0'-16;
					    if(b[t]==-1)  e[t]=t;
					    if(b[t]==-2||b[t]>0)  b[t]=t;
					    b[t]=-1;    
					}
				}
			}
		    for(i=0; i<3; i++)
			{
			    if(c[i]==0)
				{
				    for(j=0; ;j++)
					{
					    if(a[i][j]==' ')  continue;
					    if(a[i][j]=='e')  break;
					    t=a[i][j]-'0'-16;
					    b[t]=t;
					}
				}
			}
		    j=0;
		    for(i=1; i<=12; i++ )
			    if( b[i]<0 )  { c[j]=i; j++; }
		    if(j>1)
			{
			    for(i=0; i<j; i++ )
				{
				    t=c[i];
			       if(e[t]==0 )  b[t]=0;
				}
			}
		    for(i=1; i<=12; i++)
			{
			    if(b[i]<0)
				{
				    if(b[i]==-1)
					{
				         cout<<d[i]<<" is the counterfeit coin and it is heavy."<<endl;
					     break;
					}
			        if(b[i]==-2)
					{
					    cout<<d[i]<<" is the counterfeit coin and it is light."<<endl;
					    break;
					}
				}
			}
		}
	}
	return 0;
}






Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator