답안 #516046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
516046 2022-01-20T10:34:14 Z Mahdi Ili (COI17_ili) C++17
0 / 100
1 ms 204 KB
#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;
    memset(l, -1, 4*n);
    memset(r, -1, 4*n);
    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';
    }
    int z=0;
    for(int i=0;i<(1<<n);++i){
        int x=i;
        for(int j=0;j<n;++j){
            b[j]=x&1;
            x>>=1;
        }
        for(int j=n;j<n+m;++j)
            b[j]=b[l[j]]|b[r[j]];
        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;
            }
        }
        if(bl){
            for(int j=n;j<n+m;++j)
                a[j]+=b[j];
            ++z;
        }
    }
    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';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -