Submission #1050375

#TimeUsernameProblemLanguageResultExecution timeMemory
1050375makanhuliaSenior Postmen (BOI14_postmen)C++17
0 / 100
3 ms13660 KiB
#include<bits/stdc++.h> using namespace std; #define int long long bool vis[500001]; vector<pair<int,int> >adj[500001]; int sz[500001]; int tmp; void solve(int cur){ for(auto r : adj[cur]){ if(tmp!=r.first && vis[r.second]==false){ cout<<r.first<<" "; sz[cur]--; sz[r.first]--; vis[r.second]=true; solve(r.first); break; } else if(vis[r.second]==false &&tmp==r.first){ // cout<<tmp<<endl; sz[cur]--; sz[tmp]--; vis[r.second]=true; break; } } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n,m; cin>>n>>m; int cnt=0; for(int q=1;q<=m;q++){ cnt++; int u,v; cin>>u>>v; adj[u].push_back({v,cnt}); adj[v].push_back({u,cnt}); sz[u]++; sz[v]++; } for(int q=1;q<=n;q++){ if(sz[q]!=0){ // cout<<sz[q]<<endl; tmp=q; cout<<q<<" "; solve(q); cout<<endl; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...