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

Re:我来解释一下那些么明奇妙的WA

Posted by qddpx at 2012-08-17 02:00:06 on Problem 3295 and last updated at 2012-08-17 02:02:46
In Reply To:我来解释一下那些么明奇妙的WA Posted by:gyarenas at 2011-11-21 15:20:38
求解释我这段为啥也是C++WA G++AC

#include <cstdio>
#define M 105

char f[M], v[5];
int c;

int eval() {
	char v1, v2;
	switch(f[c++]) {
		case 'K':
			v1 = eval(); v2 = eval();
			return v1 && v2;
		case 'A':
			v1 = eval(); v2 = eval();
			return v1 || v2;
		case 'N':
			v1 = eval();
			return !v1;
		case 'C':
			v1 = eval(); v2 = eval();
			return !v1 || v2;
		case 'E':
			v1 = eval(); v2 = eval();
			return v1 == v2;
		default:
			return v[f[c-1] - 'p'];
	}
}

int dfs(int d) {
	if(d == 5) {
		c = 0;
		return eval();
	}
	v[d] = 0;
	if(!dfs(d+1)) return 0;
	v[d] = 1;
	return dfs(d+1);
}

int main() {
	while(scanf("%s", f) && f[0]-'0') {
		if(dfs(0)) printf("tautology\n");
		else printf("not\n");
	}
	return 0;
}

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