Submission #31539

#TimeUsernameProblemLanguageResultExecution timeMemory
31539Dat160601Senior Postmen (BOI14_postmen)C++14
0 / 100
16 ms12160 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define fi first #define se second int n,u,v,m,vis[500007],num[500007]; vector < pair<int,int> > edge[500007],ed; stack <int> res; void start(int u,int p){ int over=0; for(int i=0;i<(int)edge[u].size();i++){ int v=edge[u][i].fi; //cout<<v<<endl; if(v==p) continue; int id=edge[u][i].se; if(vis[id]==1) continue; vis[id]=1; num[u]--; num[v]--; start(v,u); } if(num[u]==0){ res.push(u); } } int main(){ ios_base::sync_with_stdio(0); cin>>n>>m; for(int i=1;i<=m;i++){ cin>>u>>v; edge[u].pb(mp(v,i)); edge[v].pb(mp(u,i)); num[u]++; num[v]++; ed.pb(mp(u,v)); } int sp=0; start(1,0); int fil=0; if(sp==1) cout<<"\n"; while(!res.empty()){ fil++; if(fil==1){} else if(fil==2) cout<<res.top(); else cout<<" "<<res.top(); res.pop(); } sp=1; }

Compilation message (stderr)

postmen.cpp: In function 'void start(int, int)':
postmen.cpp:11:9: warning: unused variable 'over' [-Wunused-variable]
     int over=0;
         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...