제출 #891948

#제출 시각아이디문제언어결과실행 시간메모리
891948HaciyevAlik어르신 집배원 (BOI14_postmen)C++14
0 / 100
2 ms4956 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mx=2e5+5; vector<pair<int,int>> g[mx],edges; bool used[mx]; int n,m; vector<int> path; void dfs(int u) { while(!g[u].empty()) { pair<int,int> cur = g[u].back(); g[u].pop_back(); if(used[cur.second]) continue; used[cur.second] = true; dfs(cur.first); } path.push_back(u); } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i=1;i<=m;++i) { int u,v; cin >> u >> v; edges.push_back({u,v}); g[u].push_back({v,i}); g[v].push_back({u,i}); } for(int i=0;i<m;++i) { if(!used[i+1]) { dfs(edges[i].first); for(auto j:path) { cout << j << " "; } path.clear(); cout << '\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...