Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
难得的1ac,贴个代码庆祝下#define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <cassert> #include <string> #include <vector> #include <algorithm> #include <map> #include <set> #include <queue> #include <sstream> #include <numeric> #include <fstream> #include <iostream> #include <utility> #include <iomanip> #include <stack> using namespace std; #define VAR(a,b) __typeof(b) a=(b) #define FOR(i, a, b) for (int i(a); i <= b; ++i) #define FORD(i, a, b) for (int i(a), _b(b); i >= _b; --i) #define REP(i, n) for (int i(0); i < n; ++i) #define REPD(i, n) for (int i((n)-1); i >= 0; --i) #define REP_1(i, n) for (int i(1); i <= n; ++i) #define REPD_1(i, n) for (int i(n); i >= 1; --i) #define ALL(c) (c).begin(), (c).end() #define FOREACH(it,c) for(VAR(it,(c).begin());it!=(c).end();++it) #define ALL(c) (c).begin(), (c).end() #define SORT(c) sort(ALL(c)) #define REVERSE(c) reverse(ALL(c)) #define UNIQUE(c) SORT(c),(c).resize(unique(ALL(c))-(c).begin()) #define INF 1000000000 #define X first #define Y second #define pb push_back #define mp make_pair #define SZ(c) (c).size() typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPII; typedef vector<VI> VVI; //template<typename T> int size(const T& c) { return (int)c.size(); } //template<typename T> void remin(T& a, const T& b) { if (b < a) a = b; } //template<typename T> void remax(T& a, const T& b) { if (b > a) a = b; } template<typename T> T abs(T x) { return x < 0 ? -x : x; } template<typename T> T sqr(T x) { return x*x; } bool isLetter(char c){return c>='A' && c<='Z' || c>='a' && c<='z';}//NOTES:isLetter( bool isDigit(char c){return c>='0' && c<='9';}//NOTES:isDigit( //template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();}//NOTES:toString( #define clr(x) memset((x), 0, sizeof(x)) //const double pi=acos(-1.0);//NOTES:pi //printf("%f\n",(float)clock()/CLOCKS_PER_SEC) int main(){ //freopen("abc.txt","r",stdin); string s; int len; bool op1,op2,input[5]; while(cin>>s,s!="0"){ stack<bool> st; len=s.length(); bool ok=true; REP(t,32){ REP(i,5) if(t&(1<<i)) input[i]=true; else input[i]=false; REPD(i,len){ switch(s[i]){ case 'p': st.push(input[0]);break; case 'q': st.push(input[1]);break; case 'r': st.push(input[2]);break; case 's': st.push(input[3]);break; case 't': st.push(input[4]);break; case 'K': op1=st.top(); st.pop(); op2=st.top(); st.pop(); st.push(op1&op2); break; case 'A': op1=st.top(); st.pop(); op2=st.top(); st.pop(); st.push(op1|op2); break; case 'N': op1=st.top(); st.pop(); st.push(!op1); break; case 'C': op1=st.top(); st.pop(); op2=st.top(); st.pop(); if(op1 && !op2) st.push(false); else st.push(true); break; case 'E': op1=st.top(); st.pop(); op2=st.top(); st.pop(); st.push(!(op1^op2)); break; } } bool res; res=st.top(); if(res==false) ok=false; st.pop(); } if(ok) cout<<"tautology"<<endl; else cout<<"not"<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator