# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
235709 | Kalam | Ili (COI17_ili) | C++11 | 1046 ms | 13560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// KALAM
# include<bits/stdc++.h>
using namespace std;
const int N = 10000 + 77;
int n , m , F[N] , G[N];
bitset < N > B[N] , P , I , E;
vector < int > adj[N];
char S[N];
int main() {
scanf("%d %d" , & n , & m);
scanf("%s" , S + 1);
for(int i = 1;i <= n;++ i)
P[i] = 1 , I[i] = 1;
for(int i = 1;i <= m;++ i) {
int k = 2;
while(k --) {
char c;
int x;
scanf(" %c%d" , & c , & x);
if(c == 'x') B[i][x] = 1 , adj[i].push_back(x);
else B[i] |= B[x] , adj[i].push_back(-x);
}
if(S[i] == '0')
P = (P & (I ^ B[i]));
}
for(int i = 1;i <= m;++ i)
B[i] &= P;
for(int i = 1;i <= m;++ i)
if(B[i] == E && S[i] == '?')
S[i] = '0';
for(int i = 1;i <= m;++ i) {
if(S[i] != '?')
continue ;
memset(F , 0 , sizeof F);
memset(G , 0 , sizeof G);
for(int j = 1;j <= n;++ j)
F[j] = (P[j] & (!B[i][j]));
for(int j = 1;j <= m;++ j) {
for(int x : adj[j]) {
if(x >= 0)
G[j] |= F[x];
else
G[j] |= G[-x];
}
}
bool good = 1;
for(int j = 1;j <= m;++ j)
if(S[j] != '?')
good &= (G[j] == (S[j] - '0'));
if(!good)
S[i] = '1';
}
for(int i = 1;i <= m;++ i)
printf("%c" , S[i]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |