POJ-1013-Counterfeit Dollar -暴力水题


http://poj.org/problem?id=1013

这代码写得太挫太长了。。。。


#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;  
struct node
{
	int len;
	char ip1[105];
	char ip2[105];
	char ip3[105]; 
	
};
node input[5];
bool cmp(node a,node b)
{
	return a.len::iterator it;
set ans;
set ans2;
int main()
{  
	int i,j;
	int t;
	cin>>t;
	while(t--)
	{
		memset(value,0,sizeof(value));
		memset(vis2,0,sizeof(vis2));
		memset(vis,0,sizeof(vis));
		ans.clear();
		ans2.clear();
		
		for (i=1;i<=3;i++)
		{
			scanf("%s %s %s",input[i].ip1,input[i].ip2,input[i].ip3);
			input[i].len=strlen(input[i].ip1);
		}
	 	sort(input+1,input+1+3,cmp);  //从长度最短的开始选可保证尽可能得到答案(set里面元素尽可能少),但是本题说明了必然有答案,所以排序不排序都不影响结果
		
		for (i=1;i<=3;i++)
		{
			int n=input[i].len;
			strcpy(tm,input[i].ip1);
			strcpy(nm,input[i].ip2);
			strcpy(result,input[i].ip3);
			
			if (strcmp(result,"even")==0)
			{
				for (j=0;jvalue[t2])
				op=1;
			else
				op=2;
			
			if (op!=1)
				printf("%c is the counterfeit coin and it is heavy.\n",(*ans2.begin()+'A'-1));
			else 
				printf("%c is the counterfeit coin and it is light.\n",(*ans.begin()+'A'-1)); 
			
			continue;
		}
		
		if (ans.size()!=1)
			printf("%c is the counterfeit coin and it is heavy.\n",(*ans2.begin()+'A'-1));
		else 
			printf("%c is the counterfeit coin and it is light.\n",(*ans.begin()+'A'-1));
		
		
}
return 0;

} 


你可能感兴趣的:(暴力)