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 songruirui at 2013-04-01 10:59:42 on Problem 1013
#include <iostream>
#include <memory.h>
#include <string>
using namespace std;
char honest[15];
string heavy;
string light;
int main()
{
	int rounds;
	cin>>rounds;
	while(rounds--)
	{
		heavy.clear();
		light.clear();
		heavy="ABCDEFGHIJKL";
		light="ABCDEFGHIJKL";
		memset(honest,0,sizeof(honest));
		for(int i=1;i<=3;i++)
		{
			string left,right,re;
			cin>>left>>right>>re;
			if(re=="even")
			{
				for(int j=0;j<=left.size()-1;j++)
				{	
					honest[left[j]-'A'+1]=true;
				}
				for(int j=0;j<=right.size()-1;j++)
				{	
					honest[right[j]-'A'+1]=true;
					
				}
			}
			else
			{
				
				if(re=="up")
				{
					//取交集
					for(int i=0;i<heavy.size();i++)
					{
						if(left.find(heavy[i])==-1)
							heavy[i]='X';
					}
					for(int i=0;i<light.size();i++)
					{
						if(right.find(light[i])==-1)
							light[i]='X';
					}
					
				}
				else
				{
					for(int i=0;i<heavy.size();i++)
					{
						if(right.find(heavy[i])==-1)
							heavy[i]='X';
					}
					for(int i=0;i<light.size();i++)
					{
						if(left.find(light[i])==-1)
							light[i]='X';
					}
				}
				for(char a='A';a<='L';a++)
				{
					if(heavy.find(a)==-1&&light.find(a)==-1)
						honest[a-'A'+1]=true;
					else if(heavy.find(a)!=-1&&light.find(a)!=-1)
						honest[a-'A'+1]=true;
				}
			}
		}
		string temp;
		for(int i=1;i<=12;i++)
		{
			if(honest[i]==false)
			{
				char c=i+'A'-1;
				if(light.find(c)!=-1)
					temp="light";
				else
					temp="heavy";
				cout<<c<<" is the counterfeit coin and it is "<<temp<<"."<<endl;
				break;
			}
		}
	}
}

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