# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
66568 | 2018-08-11T13:01:28 Z | ekrem | Ili (COI17_ili) | C++ | 5 ms | 4328 KB |
#include <bits/stdc++.h> #define st first #define nd second #define mp make_pair #define pb push_back #define N 1000005 using namespace std; int n, m, a[N], aa[N]; pair < int , int > g[N]; void yap(){ for(int i = n + m; i > n; i--){ if(a[i] == 0 and a[g[i].st] <= 0 and a[g[i].nd] <= 0){ a[g[i].st] = 0; a[g[i].nd] = 0; } if(a[g[i].st] == 0 and a[g[i].nd] == 0 and a[i] != 1) a[i] = 0; if((a[g[i].st] == 1 or a[g[i].nd] == 1) and a[i] != 0) a[i] = 1; if(a[i] == 1 and a[g[i].st] == 0 and a[g[i].nd] != 0) a[g[i].nd] = 1; if(a[i] == 1 and a[g[i].nd] == 0 and a[g[i].st] != 0) a[g[i].st] = 1; // cout << a[i] << " -> " << a[g[i].st] << " , " << a[g[i].nd] << endl; } } bool bak(){ for(int i = n + m; i > n; i--){ if(a[i] == 0){ if(a[g[i].st] == 1 or a[g[i].nd] == 1)return 0; a[g[i].st] = 0; a[g[i].nd] = 0; } } for(int i = n + m; i > n; i--){ if(a[g[i].st] == 0 and a[g[i].nd] == 0){ if(a[i] == 1)return 0; a[i] = 0; } } return 1; } int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); scanf("%d %d",&n ,&m); memset(a, -1, sizeof a); for(int i = 1; i <= m; i++){ char x; scanf(" %c",&x); if(x == '1') a[i + n] = 1; if(x == '0') a[i + n] = 0; } for(int i = 1; i <= m; i++){ int x, y; char aa, b; scanf(" %c%d %c%d",&aa ,&x ,&b ,&y); if(aa == 'c') x += n; if(b == 'c') y += n; g[i + n].st = x; g[i + n].nd = y; // cout << i + n << " -> " << x << " , " << y << endl; // cout << a[i + n] << " -> " << a[x] << " , " << a[y] << endl; } yap(); for(int i = 1; i <= n + m; i++) aa[i] = a[i]; // for(int i = n + 1; i <= n + m; i++)if(a[i] != -1)printf("%d",a[i]);else printf("?");puts(""); for(int i = n + m; i > n; i--) if(a[i] == -1){ for(int i = 1; i <= n + m; i++) a[i] = aa[i]; a[i] = 0; // cout << i << " -> " << f << endl; // for(int i = n + 1; i <= n + m; i++)if(a[i] != -1)printf("%d",a[i]);else printf("?");puts(""); if(!bak()) aa[i] = 1; } for(int i = n + 1; i <= n + m; i++) if(aa[i] != -1) printf("%d",aa[i]); else printf("?"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4180 KB | Output is correct |
2 | Correct | 5 ms | 4328 KB | Output is correct |
3 | Incorrect | 5 ms | 4328 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4180 KB | Output is correct |
2 | Correct | 5 ms | 4328 KB | Output is correct |
3 | Incorrect | 5 ms | 4328 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4180 KB | Output is correct |
2 | Correct | 5 ms | 4328 KB | Output is correct |
3 | Incorrect | 5 ms | 4328 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |