#include<initializer_list> #include<iostream> #include<queue> #include<list> #include<stdio.h> #include<vector> #include<map> #include<set> #include <cstdlib> using namespace std; #define ull long long int #define ll long long #define FOR(i, n) for(int i=0;i<n;++i) #define FORI(f, i, n) for(int i=(f);i<(n);++i) #define FORD(i, n) for(int i=(n)-1;i>=0;--i) #define znakow 26 #define dcout 0 && cout int inline min(int a, int b) { return a > b ? b : a; } int inline max(int a, int b) { return a < b ? b : a; } int main() { ios::sync_with_stdio(false); int n; cin >> n; char c; int clause=0; vector<vector<int> >game; do { cin>>c;//'('; dcout<<c; vector<int> currentClause; while(1){ cin>>c; dcout<<c; int negated=0; if(c=='~'){ negated=1; cin>>c; } int k; cin>>k; --k; dcout<<k; k<<=1; dcout<<k<<" "; if(!negated){ k|=1; } cin>>c; dcout<<c; currentClause.push_back(k); if(c==')'){ break; } //cin>>c; //cin>>c; } game.push_back(currentClause); cin>>c;dcout<<c;dcout<<"d"<<c; if(c!='^'){ break; } } while (1); int s=1<<n; dcout<<s<<endl; FOR(i, 1<<n){ int v[n]; FOR(j,n)v[j]=1&(i>>j); for(auto it = game.begin();it!=game.end();++it){ dcout<<"SET: "; int found=0; for(auto it2=it->begin();it2!=it->end();++it2){ int x = *it2; //dcout<<"."<<endl; dcout<<"var "<<(x>>1)<<" should be "<<(x&1)<<", is"<<v[x>>1]<<endl; if(v[x>>1]^(x&1)){ found=1; break; } } if(!found){ --s; break; } dcout<<endl; } } cout<<s<<endl; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | #include<initializer_list> #include<iostream> #include<queue> #include<list> #include<stdio.h> #include<vector> #include<map> #include<set> #include <cstdlib> using namespace std; #define ull long long int #define ll long long #define FOR(i, n) for(int i=0;i<n;++i) #define FORI(f, i, n) for(int i=(f);i<(n);++i) #define FORD(i, n) for(int i=(n)-1;i>=0;--i) #define znakow 26 #define dcout 0 && cout int inline min(int a, int b) { return a > b ? b : a; } int inline max(int a, int b) { return a < b ? b : a; } int main() { ios::sync_with_stdio(false); int n; cin >> n; char c; int clause=0; vector<vector<int> >game; do { cin>>c;//'('; dcout<<c; vector<int> currentClause; while(1){ cin>>c; dcout<<c; int negated=0; if(c=='~'){ negated=1; cin>>c; } int k; cin>>k; --k; dcout<<k; k<<=1; dcout<<k<<" "; if(!negated){ k|=1; } cin>>c; dcout<<c; currentClause.push_back(k); if(c==')'){ break; } //cin>>c; //cin>>c; } game.push_back(currentClause); cin>>c;dcout<<c;dcout<<"d"<<c; if(c!='^'){ break; } } while (1); int s=1<<n; dcout<<s<<endl; FOR(i, 1<<n){ int v[n]; FOR(j,n)v[j]=1&(i>>j); for(auto it = game.begin();it!=game.end();++it){ dcout<<"SET: "; int found=0; for(auto it2=it->begin();it2!=it->end();++it2){ int x = *it2; //dcout<<"."<<endl; dcout<<"var "<<(x>>1)<<" should be "<<(x&1)<<", is"<<v[x>>1]<<endl; if(v[x>>1]^(x&1)){ found=1; break; } } if(!found){ --s; break; } dcout<<endl; } } cout<<s<<endl; return 0; } |