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 magicalking at 2007-01-10 12:27:05 on Problem 1013
#include<iostream>
#include<string>
#include<algorithm>

#define Nm(x) x-65 

using namespace std;

int main(){
	
	int flag[12]={1,1,1,1,1,1,1,1,1,1,1,1},n,i,j,k,uneven=0;

	string left[3],right[3],state[3],le,ri;

	char ans;

	cin>>n;

	for(;n>0;n--,uneven=0,ri.erase(),le.erase()){

		for(i=0;i<3;i++){
			cin>>left[i]>>right[i]>>state[i];
		}

		for(j=0;j<3;j++){
			switch(state[j][0]){
			case 'e': if(left[j]==right[j])break;//if both sides are the same, jump it

				for(k=0;k<left[j].size();k++){//if not, exclude the chars
					flag[ Nm(left[j][k]) ]=0;

					flag[ Nm(right[j][k]) ]=0;
					  }
				break;

			case 'u': le+=left[j];
				ri+=right[j];
				uneven++;
				break;

			case 'd': le+=right[j];//put it in another way for convience
				ri+=left[j];
				uneven++;
			}
		}

		for(i=0;i<le.size();i++){//get the unequal string dealt with
			flag[ Nm(le[i]) ]=2;
			flag[ Nm(ri[i]) ]=2;

			if(count(le.begin(),le.end(),le[i])!=uneven){
				flag[ Nm(le[i]) ]=0;
			}

			if(count(ri.begin(),ri.end(),ri[i])!=uneven){
				flag[ Nm(ri[i]) ]=0;
			}
		}

		for(j=0;j<12;j++){//get the answer and reinitailize flag
			if(flag[j]==2){
				ans=j+65;
				break;
			}

			flag[j]=1;
		}


		cout<<ans<<" is the counterfeit coin and it is "<<(count(le.begin(),le.end(),ans)?"heavy.\n":"light.\n");

	}

}
 








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