# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
26361 | 2017-06-29T10:25:06 Z | tlwpdus | Ili (COI17_ili) | C++ | 1069 ms | 2216 KB |
#include <bits/stdc++.h> using namespace std; int n, m; char str[20100]; char ttr[20100]; int son[20100][2]; int getn(char str[]) { int i, x = 0; for (i=0;str[i]>='0'&&str[i]<='9';i++) { x *=10; x+=str[i]-'0'; } return x; } bool can0(int idx) { int i; for (i=0;i<n+m;i++) ttr[i] = str[i]; ttr[idx] = '0'; for (i=n+m;i>=n;i--) { if (ttr[i]=='0') { if (ttr[son[i][0]]=='1'||ttr[son[i][1]]=='1') return false; ttr[son[i][1]]=ttr[son[i][0]]='0'; } } for (i=n;i<n+m;i++) { if (ttr[son[i][0]]=='0'&&ttr[son[i][1]]=='0') { if (ttr[i]=='1') return false; ttr[i]='0'; } } for (i=n;i<n+m;i++) { if (ttr[i]=='?') { if (ttr[son[i][0]]=='0'&&ttr[son[i][1]]=='0') ttr[i]='0'; else ttr[i]='1'; } if (ttr[i]=='1'&&ttr[son[i][0]]=='0'&&ttr[son[i][1]]=='0') return false; if (ttr[i]=='0'&&(ttr[son[i][0]]=='1'||ttr[son[i][1]]=='1')) return false; } return true; } int main() { int i, j; //freopen("input","r",stdin); scanf("%d%d",&n,&m); scanf("%s",str+n); fill(str,str+n,'?'); for (i=0;i<m;i++) { char buf[10]; for (j=0;j<2;j++) { int x = 0; scanf("%s",buf); if (buf[0]=='c') x+= n; x+=getn(buf+1)-1; son[i+n][j] = x; } } for (i=n+m-1;i>=n;i--) { if (str[i]=='0') { str[son[i][1]]=str[son[i][0]]='0'; } } for (i=n;i<n+m;i++) { if (str[son[i][0]]=='0'&&str[son[i][1]]=='0') str[i]='0'; } for (i=n;i<n+m;i++) { if (str[i]=='?') { if (!can0(i)) str[i] = '1'; } } printf("%s\n",str+n); return 0; }
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 | 43 ms | 2216 KB | Output is correct |
16 | Correct | 416 ms | 2216 KB | Output is correct |
17 | Correct | 299 ms | 2216 KB | Output is correct |
18 | Correct | 626 ms | 2216 KB | Output is correct |
19 | Correct | 319 ms | 2216 KB | Output is correct |
20 | Correct | 1069 ms | 2216 KB | Output is correct |
21 | Correct | 793 ms | 2216 KB | Output is correct |
22 | Correct | 113 ms | 2216 KB | Output is correct |
23 | Correct | 113 ms | 2216 KB | Output is correct |
24 | Correct | 103 ms | 2216 KB | Output is correct |
25 | Correct | 236 ms | 2216 KB | Output is correct |
26 | Correct | 229 ms | 2216 KB | Output is correct |
27 | Correct | 239 ms | 2216 KB | Output is correct |
28 | Correct | 243 ms | 2216 KB | Output is correct |
29 | Correct | 246 ms | 2216 KB | Output is correct |
30 | Correct | 233 ms | 2216 KB | Output is correct |
31 | Correct | 283 ms | 2216 KB | Output is correct |
32 | Correct | 276 ms | 2216 KB | Output is correct |