# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26359 | 2017-06-29T10:20:57 Z | tlwpdus | Ili (COI17_ili) | C++ | 0 ms | 2136 KB |
#include <bits/stdc++.h> using namespace std; int n, m; char str[20100]; char ttr[20100]; int son[10100][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=idx;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[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[i]=='?') { if (!can0(i)) str[i] = '1'; } } printf("%s\n",str+n); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2136 KB | Output is correct |
2 | Correct | 0 ms | 2136 KB | Output is correct |
3 | Incorrect | 0 ms | 2136 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2136 KB | Output is correct |
2 | Correct | 0 ms | 2136 KB | Output is correct |
3 | Incorrect | 0 ms | 2136 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2136 KB | Output is correct |
2 | Correct | 0 ms | 2136 KB | Output is correct |
3 | Incorrect | 0 ms | 2136 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |