제출 #1242538

#제출 시각아이디문제언어결과실행 시간메모리
1242538minhpkSenior Postmen (BOI14_postmen)C++20
38 / 100
1095 ms39980 KiB
#include <bits/stdc++.h> #define int long long using namespace std; vector <pair<int,int>> z[1000005]; bool del[1000005]; bool vis[1000005]; stack<int> st; vector <int> pos; vector <vector<int>> res; int sl[1000005]; int cur[1000005]; void dfs(int i){ for (auto p:z[i]){ if (del[p.second]){ continue; } del[p.second]=true; dfs(p.first); } pos.push_back(i); } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int a,b; cin >> a >> b; for (int i=1;i<=b;i++){ int x,y; cin >> x >> y; z[x].push_back({y,i}); z[y].push_back({x,i}); sl[x]++; sl[y]++; } vector <int> pre; dfs(1); for (auto p:pos){ if (vis[p]){ vector <int> pre; int v=0; while (v!=p){ v=st.top(); st.pop(); vis[v]=false; pre.push_back(v); } res.push_back(pre); } vis[p]=true; st.push(p); } for (auto c:res){ for (auto p:c){ cout << p << " "; } cout << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...