This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(v) v.begin(), v.end()
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
const int N=50;
int n, m, l[N], r[N], a[N], b[N];
string s;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n>>m>>s;
for(int i=0;i<m;++i){
string x;
cin>>x;
if(x[0]=='x')
l[i+n]=x[1]-'1';
else
l[i+n]=n+x[1]-'1';
cin>>x;
if(x[0]=='x')
r[i+n]=x[1]-'1';
else
r[i+n]=n+x[1]-'1';
}
for(int i=n;i<n+m;++i){
cout<<i<<" : "<<l[i]<<", "<<r[i]<<'\n';
}
int z=0;
for(int i=0;i<(1<<n);++i){
int x=i;
for(int j=0;j<n;++j){
b[j]=x%2;
x/=2;
}
for(int j=n;j<n+m;++j){
if(b[l[j]]==1 || b[r[j]]==1)
b[j]=1;
else
b[j]=0;
}
bool bl=true;
for(int j=0;j<m;++j){
if((s[j]=='1' && b[j+n]==0) || (s[j]=='0' && b[j+n]==1)){
bl=0;
break;
}
}
cout<<i<<" : "<<bl<<'\n';
for(int j=0;j<n+m;++j)
cout<<b[j]<<' ';
cout<<'\n';
if(bl){
for(int j=n;j<n+m;++j)
a[j]+=b[j];
++z;
}
}
if(z==0){
cout<<s;
return 0;
}
for(int i=n;i<n+m;++i){
if(a[i]==0)
cout<<'0';
else if(a[i]==z)
cout<<'1';
else
cout<<'?';
}
cout<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |