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 jiangwuqwe at 2010-05-21 11:38:45 on Problem 3295
#include <stdio.h>
#include <string.h>
//#include <windows.h>

int p,q,r,s,t;
char str[101];

int tautology(int start,int end)
{
	int i;
	int x=0,y=0;
	if(str[start] == 'N')
		return !tautology(start+1,end);
	for(i=start+1;i<=end;i++)
	{
		if(str[i]>'a')x++;
		if(str[i]<'Z'&&str[i]!='N')y++;
		if(x==y+1)break;
	}

	switch(str[start])
	{
	case 'q':return q;
	case 'p':return p;
	case 'r':return r;
	case 's':return s;
	case 't':return t;
	case 'A':
		//printf("A()%d\n",tautology(start+1,i)||tautology(i+1,end));
		return tautology(start+1,i)||tautology(i+1,end);
	case 'K':
		//printf("K()%d\n",tautology(start+1,i)&&tautology(i+1,end));
		return tautology(start+1,i)&&tautology(i+1,end);
// 	case 'N':
// 		//printf("N()%d\n",!tautology(start+1,end));
// 		return !tautology(start+1,end);
	case 'C':
		//printf("C()%d\n",!tautology(start+1,i)||tautology(i+1,end));
		return !tautology(start+1,i)||tautology(i+1,end);
	case 'E':
		//printf("C()%d\n",tautology(start+1,i)==tautology(i+1,end));
		return tautology(start+1,i)==tautology(i+1,end);
	}
	return 0;
}

int main()
{
	
	int len,res,flag;
	//long start = GetTickCount();
	//char ch[]={'A','W','C','E'};
	
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	while (gets(str))
	{
		if(!strcmp(str,"0"))break;
		len = strlen(str);
		flag = 1;
		for(p=0;p<=1;p++)
			for(q=0;q<=1;q++)
				for(r=0;r<=1;r++)
					for(s=0;r<=1;r++)
						for(t=0;t<=1;t++)
						{
							if (!flag)continue;
							//printf("p=%d q=%d r=%d s=%d t=%d\n",p,q,r,s,t);
							res = tautology(0,len-1);
							if(res==0)flag = 0;
						}
			if (flag) printf("tautology\n");
			else printf("not\n");
	}
	//printf("%d ms\n",GetTickCount()-start);
	return 0;
}




//这组过不了
//NKAEEACEKKCCCKKAAECACAECAEKKECKAAAECCCKEAACArqpsrstpqsspsppssrpsprstsqspsspptrqrprptstps

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