Submission #66325

#TimeUsernameProblemLanguageResultExecution timeMemory
66325yusufakeIli (COI17_ili)C++98
0 / 100
3 ms376 KiB
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define st first #define nd second typedef long long ll; typedef pair < int , int > pp; const int mod = 1e9 + 7; const int N = 1e3 + 2; vector < int > V[N]; int H[N],Q[N],T[N],A[N],B[N],n,m,i,j,k; string a; char s[N]; int f(string a){ int i, x = 0; for(i=1; i<a.size(); i++){ x = x*10 + a[i]-'0'; } if(a[0] == 'x') x += m; return x; } void g(int x){ if(x==0) return; g(A[x]); g(B[x]); H[x] = 1; } void h(int x){ if(x==0) return; h(A[x]); h(B[x]); if(!H[x] && x > m) V[i].pb(x); } int main(){ scanf("%d%d %s",&n,&m,s+1); for(i=1;i<=m;i++){ cin >> a; A[i] = f(a); cin >> a; B[i] = f(a); // cout << i << " " << A[i] << " " << B[i] << " aa\n"; } for(i=1;i<=m;i++) if(s[i] == '0') g(i); for(i=1;i<=m;i++){ if(s[i] == '0') continue; if(s[i] == '1'){ h(i); T[i] = 1; continue; } h(i); for(auto x : V[i]) Q[x] = 1; for(j=1;j<i;j++) if(T[j]){ for(k=0; k<V[j].size(); k++) if(!Q[ V[j][k] ]) break; if(k == V[j].size()) { s[i] = '1'; break; } } for(auto x : V[i]) Q[x] = 0; } printf("%s",s+1); return 0; }

Compilation message (stderr)

ili.cpp: In function 'int f(std::__cxx11::string)':
ili.cpp:21:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=1; i<a.size(); i++){
                  ~^~~~~~~~~
ili.cpp: In function 'int main()':
ili.cpp:63:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(k=0; k<V[j].size(); k++)
                          ~^~~~~~~~~~~~
ili.cpp:66:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(k == V[j].size()) { s[i] = '1'; break; }
                    ~~^~~~~~~~~~~~~~
ili.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d %s",&n,&m,s+1);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...