Submission #52191

#TimeUsernameProblemLanguageResultExecution timeMemory
52191SmelskiySynchronization (JOI13_synchronization)C++14
20 / 100
8047 ms14432 KiB
#include <bits/stdc++.h> using namespace std; int n,m,qq; int ans; vector<pair<int,int> > v[200005]; int f[200005]; int last[200005]; int c[200005]; int x,y; void dfs(int x,int y,int xx,int yy) { if (xx<=yy) ++ans; for (int i=0;i<v[x].size();++i) { int to=v[x][i].first; if (to==y) continue; int xx2; int yy2=min(yy,last[v[x][i].second]); xx2=f[v[x][i].second]; dfs(to,x,xx2,yy2); } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>m>>qq; for (int i=1;i<n;++i) { cin>>x>>y; v[x].push_back(make_pair(y,i)); v[y].push_back(make_pair(x,i)); f[i]=m+2; last[i]=m+1; } for (int i=1;i<=m;++i) { cin>>x; c[x]^=1; if (c[x]) { f[x]=min(f[x],i); } else last[x]=i; } for (int i=1;i<n;++i) { if (c[i]) last[i]=m+1; } for (int i=1;i<=qq;++i) { cin>>x; ans=0; dfs(x,-1,0,1e9); cout<<ans<<'\n'; } }

Compilation message (stderr)

synchronization.cpp: In function 'void dfs(int, int, int, int)':
synchronization.cpp:16:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v[x].size();++i) {
                  ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...