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

求高手帮忙!

Posted by dan317423892 at 2007-12-15 14:18:43 on Problem 1013
#include<iostream>
using namespace std;
int main()
{
	int a[13],i,j;//0 1 2 3  未知  轻币  正常  重币
	char str1[5],str2[5],str3[5],s1[5]="even",s2[5]="up";
	int n;
	cin>>n;
	while(n--)
	{
	   int flag=3;
	   for(i=1;i<=12;i++)
			 a[i]=0;
	   while(flag--)
	   {
		  
		  scanf("%s %s %s",str1,str2,str3);
		  if(str3[0]=='e') //平衡都为正常
		  {
			 for(i=0;i<4;i++) 
			 {
				//左边
				 a[str1[i]-'A'+1]=2;
				//右边
				 a[str2[i]-'A'+1]=2;
			 }
		  }
		  else if(str3[0]=='u')//右边起来  右边轻了,左边重了
		  {
			 for(i=0;i<4;i++) 
			 {
				 //左边重
				if(a[str1[i]-'A'+1]==0)
				   a[str1[i]-'A'+1]=3;
				if(a[str1[i]-'A'+1]==1)//如果原先为轻的现在又为重的 则是正常的
				   a[str1[i]-'A'+1]=2;
                

				 //右边轻
				if(a[str2[i]-'A'+1]==0)
				   a[str2[i]-'A'+1]=1;	
				if(a[str2[i]-'A'+1]==3)//如果原先为重的现在又为轻的 则是正常的
				   a[str2[i]-'A'+1]=2;							
				
				
			 }	
		  }
		  else                   //右边下沉,右边重了,左边轻了
		  {
			  for(i=0;i<4;i++)
			  {  
				  //左边轻
			      if(a[str1[i]-'A'+1]==0)//左边轻了
				     a[str1[i]-'A'+1]=1;
			      if(a[str1[i]-'A'+1]==3)//如果原先为重的现在又为轻的 则是正常的
				     a[str1[i]-'A'+1]=2;
			      //右边重
			      if(a[str2[i]-'A'+1]==0)//右边重了
				     a[str2[i]-'A'+1]=2;
			      if(a[str2[i]-'A'+1]==1)//如果原先为轻的现在又为重的 则是正常的
				     a[str2[i]-'A'+1]=2;
			  }

		  }
	   } 
	   for(i=1;i<=12;i++)
	   {
		   if(a[i]==1)
		   {
				cout<<(char)('A'+i-1)<<" is the counterfeit coin and it is light."<<endl;
			    break;
		   }
		   if(a[i]==3)
		   {
				 cout<<(char)('A'+i-1)<<" is the counterfeit coin and it is heavy."<<endl;
			     break;
		   }
	   }
	   
	}
}

/*
Sample Input
1
ABCD EFGH e
ABCK GHIL u
ABGH HIKL d

k heavy

1 
ABCD EFGH even 
ABCI EFJK up 
ABIJ EFGH even 

Sample Output


K is the counterfeit coin and it is light. 
	*/
			

			
			

			

			
			
				

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