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

Re:实在没辙了。我先是用排除法做,WA,后来没办法改用暴力,还是WA,请高手指教。

Posted by liberty752 at 2005-09-29 15:20:30 on Problem 1013
In Reply To:实在没辙了。我先是用排除法做,WA,后来没办法改用暴力,还是WA,请高手指教。 Posted by:tdzl2003 at 2005-07-26 08:08:06
直接枚举就可以过.
> #include <iostream>
> #include <string.h>
> using namespace std;
> 
> int Flag[12];
> int Up[8][8],Upl;
> 
> int main()
> {
> 	char Buffer[8],Buffer1[10];
> 	int n,n1;
> 	cin>>n;
> 	for (n1=0;n1<n;n1++)
> 	{
> 		int i,j,k,l;
> 
> 		for (i=0;i<12;i++)	Flag[i]=0;
> 		Upl=0;
> 		for (i=0;i<3;i++)
> 		{
> 			for (j=0;j<8;j++)
> 			{
> 				cin>>Buffer[j];
> 				while (Buffer[j]<'A' || Buffer[j]>'L')
> 					cin>>Buffer[j];
> 			}
> 			for (j=0;j<2;j++)
> 			{
> 				cin>>Buffer1[j];
> 				while (Buffer1[j]<'a' || Buffer1[j]>'z')
> 					cin>>Buffer1[j];
> 			}
> 			Buffer1[2]=Buffer1[4]=0;
> 			if (Buffer1[0]!='u')
> 				for (j=0;j<2;j++)
> 				{
> 					cin>>Buffer1[j+2];
> 					while (Buffer1[j+2]<'a' || Buffer1[j+2]>'z')
> 						cin>>Buffer1[j+2];
> 				}
> 			if (!strcmp(Buffer1,"even"))
> 			{
> 				for (j=0;j<8;j++)
> 				{
> 					Flag[Buffer[j]-'A']=1;
> 				}
> 			}
> 			else if(!strcmp(Buffer1,"up"))
> 			{
> 				for (j=0;j<8;j++)Up[Upl][j]=Buffer[j]-'A';
> 				Upl++;
> 			}
> 			else // if (!strcmp(Buffer1,"down"))
> 			{
> 				for (j=0;j<4;j++)
> 				{
> 					Up[Upl][j]=Buffer[j+4]-'A';
> 					Up[Upl][j+4]=Buffer[j]-'A';
> 				}
> 				Upl++;
> 			}
> 		}
> 		for (i=0;i<12;i++)
> 			if (Flag[i]!=1)
> 			{
> 				l=1;
> 				for (j=0;j<Upl;j++)
> 				{
> 					for (k=0;k<4;k++)
> 						if (Up[j][k]==i)	break;
> 					if (k==4) l=0;
> 				}
> 				if (l)
> 				{
> 					cout<<(char)(i+'A')<<" is the counterfeit coin and it is heavy."<<endl;
> 				}
> 				l=1;
> 				for (j=0;j<Upl;j++)
> 				{
> 					for (k=4;k<8;k++)
> 						if (Up[j][k]==i)	break;
> 					if (k==8) l=0;
> 				}
> 				if (l)
> 				{
> 					cout<<(char)(i+'A')<<" is the counterfeit coin and it is light."<<endl;
> 				}
> 			}
> 	}
> }

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