# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26328 | khsoo01 | Ili (COI17_ili) | C++11 | 1909 ms | 2216 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.
#include<bits/stdc++.h>
using namespace std;
const int N = 20005;
int n, m, in[N][2];
char a[N], b[N];
bool pos () {
for(int i=1;i<=n+m;i++) b[i] = a[i];
for(int i=n+m;i>n;i--) {
if(b[i] == '0') {
for(auto &T : in[i]) {
if(b[T] == '1') return false;
if(b[T] == '?') b[T] = '0';
}
}
}
for(int i=1;i<=n;i++) {
if(b[i] == '?') b[i] = '1';
}
for(int i=n+1;i<=n+m;i++) {
if(b[i] == '?') {
if(b[in[i][0]] == '0' && b[in[i][1]] == '0') b[i] = '0';
else b[i] = '1';
}
else if(b[i] == '1' && b[in[i][0]] == '0' && b[in[i][1]] == '0') return false;
}
return true;
}
int main()
{
scanf("%d%d%s",&n,&m,a+1);
rotate(a+1, a+n+m+1, a+m+1);
for(int i=1;i<=n;i++) a[i] = '?';
for(int i=n+1;i<=n+m;i++) {
char A[15], B[15];
scanf("%s%s",A,B);
for(int j=1;A[j];j++) {
in[i][0] *= 10;
in[i][0] += A[j] - '0';
}
for(int j=1;B[j];j++) {
in[i][1] *= 10;
in[i][1] += B[j] - '0';
}
if(A[0] == 'c') in[i][0] += n;
if(B[0] == 'c') in[i][1] += n;
}
for(int i=n+1;i<=n+m;i++) {
if(a[i] != '?') putchar(a[i]);
else {
bool b1, b2;
a[i] = '1'; b1 = pos();
a[i] = '0'; b2 = pos();
if(b1 && b2) putchar('?');
else putchar('0'+b1);
a[i] = '?';
}
}
puts("");
}
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... |