제출 #1262408

#제출 시각아이디문제언어결과실행 시간메모리
1262408EntityPlanttSenior Postmen (BOI14_postmen)C++20
0 / 100
6 ms12104 KiB
#include <bits/stdc++.h> using namespace std; constexpr int N = 5e5; vector<int> g[N]; int vis[N]; set<int> path; int dfs(int u) { path.insert(u); while (!g[u].empty()) { int v = g[u].back(); g[v].erase(find(g[v].begin(), g[v].end(), u)); g[u].pop_back(); if (path.count(v)) { path.erase(u); cout << u + 1 << ' '; return v; } int r = dfs(v); if (r != u) { path.erase(u); cout << u + 1 << ' '; return r; } else cout << u + 1 << '\n'; } return -1; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; while (m--) { int a, b; cin >> a >> b; g[--a].push_back(--b); g[b].push_back(a); } dfs(0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...