Submission #66567

#TimeUsernameProblemLanguageResultExecution timeMemory
66567ekremIli (COI17_ili)C++98
0 / 100
7 ms4384 KiB
#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] == 1 and a[g[i].st] == 0 and a[g[i].nd] == 0) return 0; if(a[i] == 0 and (a[g[i].st] == 1 or a[g[i].nd] == 1)) return 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){ a[i] = 0; yap(); bool f = bak(); // cout << i << " -> " << f << endl; // for(int i = n + 1; i <= n + m; i++)if(a[i] != -1)printf("%d",a[i]);else printf("?");puts(""); for(int i = 1; i <= n + m; i++) a[i] = aa[i]; if(!f){ a[i] = 1; 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("?"); return 0; }

Compilation message (stderr)

ili.cpp: In function 'int main()':
ili.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n ,&m);
  ~~~~~^~~~~~~~~~~~~~~~
ili.cpp:49:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c",&x);
   ~~~~~^~~~~~~~~~
ili.cpp:59:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c%d %c%d",&aa ,&x ,&b ,&y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...