Submission #465873

# Submission time Handle Problem Language Result Execution time Memory
465873 2021-08-17T03:52:43 Z SirCovidThe19th Ili (COI17_ili) C++17
0 / 100
1 ms 716 KB
#include <bits/stdc++.h>
using namespace std; 

int n, m; vector<char> A; vector<int> in[20005];

void set0(vector<char> &X, int i){
    X[i] = '0'; 
    for (auto nxt : in[i]) if (X[nxt] != '0') set0(X, nxt);
}

int main(){
    cin >> n >> m; A.resize(n + m);
    for (int i = 0; i < n + m; i++){
        if (i < n) A[i] = '?';
        else cin >> A[i];
    }
    for (int i = n, u, v; i < n + m; i++){
        string a, b; cin >> a >> b;
        u = a[1] - '1' + (a[0] == 'c' ? n : 0);
        v = b[1] - '1' + (b[0] == 'c' ? n : 0);
        in[i].push_back(u); in[i].push_back(v);
    }
    for (int i = n; i < n + m; i++) if (A[i] == '0') set0(A, i);
    
    for (int i = n; i < n + m; i++){
        if (A[i] == '?'){
            bool ok = 1; vector<char> tmp = A; set0(tmp, i);
            for (int x = n; x < n + m; x++){
                char &in1 = tmp[in[x][0]], &in2 = tmp[in[x][1]], &cur = tmp[x];
                if (in1 == '0' and in2 == '0') cur = '0';
                if (in1 == '1' or in2 == '1') cur = '1';
                if (A[x] != '?' and cur != A[x]){ ok = 0; break; }
            }
            cout<<(ok ? '?' : '1');
        }
        else cout<<A[i];
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Incorrect 1 ms 716 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Incorrect 1 ms 716 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Incorrect 1 ms 716 KB Output isn't correct
4 Halted 0 ms 0 KB -