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 awq123 at 2011-08-02 23:11:20 on Problem 1013
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin); 
	int i,j,len,n,d[12],temp[12];
	char left[12],right[12],cmp[4];
	scanf("%d",&n);
	while(n--)
	{
		memset(d,0,sizeof(d));
		for(i=0;i<3;i++)
		{
			scanf("%s%s%s",left,right,cmp);
			len=strlen(left);
			if(cmp[0]=='e')
			{
				for(j=0;j<len;j++)
				{
					d[left[j]-'A']=1;
					d[right[j]-'A']=1;
				}
			}
			else if(cmp[0]=='u')
			{
				memset(temp,0,sizeof(temp));
				for(j=0;j<len;j++)
				{
					if(d[left[j]-'A']==-1)
						d[left[j]-'A']=1;
					else if(d[left[j]-'A']==0)
						d[left[j]-'A']=2;
					if(d[right[j]-'A']==2)
						d[right[j]-'A']=1;
					else if(d[right[j]-'A']==0)
						d[right[j]-'A']=-1;
					temp[left[j]-'A']=1;
					temp[right[j]-'A']=1;
				}
				for(j=0;j<12;j++)
					if(temp[j]==0)
						d[j]=1;
			}
			else if(cmp[0]=='d')
			{
				memset(temp,0,sizeof(temp));
				for(j=0;j<len;j++)
				{
					if(d[left[j]-'A']==2)
						d[left[j]-'A']=1;
					else if(d[left[j]-'A']==0)
						d[left[j]-'A']=-1;
					if(d[right[j]-'A']==-1)
						d[right[j]-'A']=1;
					else if(d[right[j]-'A']==0)
						d[right[j]-'A']=2;
					temp[left[j]-'A']=1;
					temp[right[j]-'A']=1;
				}
				for(j=0;j<12;j++)
					if(temp[j]==0)
						d[j]=1;
			}
		}
		for(i=0;i<12;i++)
		{
			if(d[i]==-1)
				printf("%c is the counterfeit coin and it is light.\n",i+'A');
			if(d[i]==2)
				printf("%c is the counterfeit coin and it is heavy.\n",i+'A');
		}	
	}
}

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