Submission #26328

#TimeUsernameProblemLanguageResultExecution timeMemory
26328khsoo01Ili (COI17_ili)C++11
100 / 100
1909 ms2216 KiB
#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 (stderr)

ili.cpp: In function 'int main()':
ili.cpp:33:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%s",&n,&m,a+1);
                           ^
ili.cpp:38:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s%s",A,B);
                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...