# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
26305 | 2017-06-29T06:09:52 Z | 김현수(#1102) | Ili (COI17_ili) | C++11 | 1969 ms | 2216 KB |
#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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2216 KB | Output is correct |
2 | Correct | 0 ms | 2216 KB | Output is correct |
3 | Correct | 0 ms | 2216 KB | Output is correct |
4 | Correct | 0 ms | 2216 KB | Output is correct |
5 | Correct | 0 ms | 2216 KB | Output is correct |
6 | Correct | 0 ms | 2216 KB | Output is correct |
7 | Correct | 0 ms | 2216 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2216 KB | Output is correct |
2 | Correct | 0 ms | 2216 KB | Output is correct |
3 | Correct | 0 ms | 2216 KB | Output is correct |
4 | Correct | 0 ms | 2216 KB | Output is correct |
5 | Correct | 0 ms | 2216 KB | Output is correct |
6 | Correct | 0 ms | 2216 KB | Output is correct |
7 | Correct | 0 ms | 2216 KB | Output is correct |
8 | Correct | 0 ms | 2216 KB | Output is correct |
9 | Correct | 0 ms | 2216 KB | Output is correct |
10 | Correct | 0 ms | 2216 KB | Output is correct |
11 | Correct | 0 ms | 2216 KB | Output is correct |
12 | Correct | 0 ms | 2216 KB | Output is correct |
13 | Correct | 0 ms | 2216 KB | Output is correct |
14 | Correct | 0 ms | 2216 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2216 KB | Output is correct |
2 | Correct | 0 ms | 2216 KB | Output is correct |
3 | Correct | 0 ms | 2216 KB | Output is correct |
4 | Correct | 0 ms | 2216 KB | Output is correct |
5 | Correct | 0 ms | 2216 KB | Output is correct |
6 | Correct | 0 ms | 2216 KB | Output is correct |
7 | Correct | 0 ms | 2216 KB | Output is correct |
8 | Correct | 0 ms | 2216 KB | Output is correct |
9 | Correct | 0 ms | 2216 KB | Output is correct |
10 | Correct | 0 ms | 2216 KB | Output is correct |
11 | Correct | 0 ms | 2216 KB | Output is correct |
12 | Correct | 0 ms | 2216 KB | Output is correct |
13 | Correct | 0 ms | 2216 KB | Output is correct |
14 | Correct | 0 ms | 2216 KB | Output is correct |
15 | Correct | 349 ms | 2216 KB | Output is correct |
16 | Correct | 849 ms | 2216 KB | Output is correct |
17 | Correct | 1063 ms | 2216 KB | Output is correct |
18 | Correct | 913 ms | 2216 KB | Output is correct |
19 | Correct | 956 ms | 2216 KB | Output is correct |
20 | Correct | 1969 ms | 2216 KB | Output is correct |
21 | Correct | 1636 ms | 2216 KB | Output is correct |
22 | Correct | 329 ms | 2216 KB | Output is correct |
23 | Correct | 289 ms | 2216 KB | Output is correct |
24 | Correct | 299 ms | 2216 KB | Output is correct |
25 | Correct | 383 ms | 2216 KB | Output is correct |
26 | Correct | 363 ms | 2216 KB | Output is correct |
27 | Correct | 369 ms | 2216 KB | Output is correct |
28 | Correct | 356 ms | 2216 KB | Output is correct |
29 | Correct | 336 ms | 2216 KB | Output is correct |
30 | Correct | 406 ms | 2216 KB | Output is correct |
31 | Correct | 356 ms | 2216 KB | Output is correct |
32 | Correct | 376 ms | 2216 KB | Output is correct |