Submission #235709

#TimeUsernameProblemLanguageResultExecution timeMemory
235709KalamIli (COI17_ili)C++11
100 / 100
1046 ms13560 KiB
// KALAM # include<bits/stdc++.h> using namespace std; const int N = 10000 + 77; int n , m , F[N] , G[N]; bitset < N > B[N] , P , I , E; vector < int > adj[N]; char S[N]; int main() { scanf("%d %d" , & n , & m); scanf("%s" , S + 1); for(int i = 1;i <= n;++ i) P[i] = 1 , I[i] = 1; for(int i = 1;i <= m;++ i) { int k = 2; while(k --) { char c; int x; scanf(" %c%d" , & c , & x); if(c == 'x') B[i][x] = 1 , adj[i].push_back(x); else B[i] |= B[x] , adj[i].push_back(-x); } if(S[i] == '0') P = (P & (I ^ B[i])); } for(int i = 1;i <= m;++ i) B[i] &= P; for(int i = 1;i <= m;++ i) if(B[i] == E && S[i] == '?') S[i] = '0'; for(int i = 1;i <= m;++ i) { if(S[i] != '?') continue ; memset(F , 0 , sizeof F); memset(G , 0 , sizeof G); for(int j = 1;j <= n;++ j) F[j] = (P[j] & (!B[i][j])); for(int j = 1;j <= m;++ j) { for(int x : adj[j]) { if(x >= 0) G[j] |= F[x]; else G[j] |= G[-x]; } } bool good = 1; for(int j = 1;j <= m;++ j) if(S[j] != '?') good &= (G[j] == (S[j] - '0')); if(!good) S[i] = '1'; } for(int i = 1;i <= m;++ i) printf("%c" , S[i]); return 0; }

Compilation message (stderr)

ili.cpp: In function 'int main()':
ili.cpp:12:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d" , & n , & m);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~
ili.cpp:13:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%s" , S + 1);
    ~~~~~^~~~~~~~~~~~~~
ili.cpp:21:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
          scanf(" %c%d" , & c , & x);
          ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...