简单模拟,我把变量少看了一个Runtime Error到死,还以为是哪里错了,蒟蒻都是这样orz。
ACcode:
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%lf%lf",&x,&y)
#define rds(x) scanf("%s",x)
#define rdc(x) scanf("%c",&x)
#define ll long long int
#define maxn 100005
#define mod 1000000007
#define INF 0x3f3f3f3f //int 最大值
#define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;++i)
#define MT(x,i) memset(x,i,sizeof(x))
#define PI acos(-1.0)
#define E exp(1)
using namespace std;
string str;
int len;
bool flag;
int fun(int p,int q,int r,int s,int t){
stack<int>st;
//cout<<p<<' '<<q<<' '<<s<<' '<<t<<" ";
for(int i=len-1;i>=0;i--){
if(str[i]=='p')st.push(p);
else if(str[i]=='q')st.push(q);
else if(str[i]=='r')st.push(r);
else if(str[i]=='s')st.push(s);
else if(str[i]=='t')st.push(t);
else if(str[i]=='N'){
int t=st.top();st.pop();
st.push(!t);
}else if(str[i]=='K'){
int x=st.top();st.pop();
int w=st.top();st.pop();
st.push(w==1&&x==1);
}else if(str[i]=='A'){
int x=st.top();st.pop();
int w=st.top();st.pop();
st.push(w||x);
}
else if(str[i]=='C'){
int x=st.top();st.pop();
int w=st.top();st.pop();
st.push(!(w==1&&x==0));
}else if(str[i]=='E'){
int x=st.top();st.pop();
int w=st.top();st.pop();
st.push(w==x);
}
}
// cout<<st.top()<<"\n------------------------\n";
return st.top();
}
int main(){
while(cin>>str){
if(str[0]=='0')
break;
len=str.length();
flag=true;
FOR(p,0,1)
FOR(q,0,1)
FOR(r,0,1)
FOR(s,0,1)
FOR(t,0,1)
if(!fun(p,q,r,s,t)){
//cout<<"asdasdadas\n";
flag=false;
break;
}
printf(flag?"tautology\n":"not\n");
}
return 0;
}
/**
ApNp
ApNq
0
**/