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

为什么会TLE呢??

Posted by yangkeao at 2016-07-29 21:29:41 on Problem 3295
代码如下


#include <cstdio>
using namespace std;
char s[7000];
bool calc(char s[], int pos, bool p, bool q, bool r, bool _s, bool t) {
  if (s[pos] == 'N') return !calc(s,pos+1, p, q, r, _s, t);
  else if (s[pos] == 'K') return calc(s, pos + 1, p, q, r, _s, t) && calc(s, pos + 2, p, q, r, _s, t);
  else if (s[pos] == 'A') return calc(s, pos + 1, p, q, r, _s, t) || calc(s, pos + 2, p, q, r, _s, t);
  else if (s[pos] == 'C') return (!(!calc(s, pos + 1, p, q, r, _s, t)) || calc(s, pos + 2, p, q, r, _s, t));
  else if (s[pos] == 'E') return !(calc(s, pos + 1, p, q, r, _s, t) ^ calc(s, pos + 2, p, q, r, _s, t));
  else if (s[pos] == 'p') return p;
  else if (s[pos] == 'q') return q;
  else if (s[pos] == 'r') return r;
  else if (s[pos] == 's') return _s;
  else if (s[pos] == 't') return t;
}
int main() {
  scanf("%s", &s);
  while (s[0] != '0') {
    bool k = 1;
    for (int arg = 0; arg < 32; arg++) {
      bool p = arg & 1;
      bool q = (arg & 2)/2;
      bool r = (arg & 4)/4;
      bool _s = (arg & 8)/8;
      bool t = (arg & 16)/16;
      if (!calc(s, 0, p, q, r, _s, t)) k = 0;
    }
    if (k) printf("tautology\n");
    else printf("not\n");
    scanf("%s", &s);
  }
  return 0;
}

为什么会TLE呢?很奇怪。

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