제출 #1050328

#제출 시각아이디문제언어결과실행 시간메모리
1050328devariaota어르신 집배원 (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(tmp==r.first){ //cout<<tmp<<endl; sz[cur]--; sz[tmp]--; vis[r.second]=true; } } } signed main(){ 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...