Submission #465924

#TimeUsernameProblemLanguageResultExecution timeMemory
465924prvocisloSenior Postmen (BOI14_postmen)C++17
0 / 100
8 ms12236 KiB
#include <iostream> #include <vector> #include <list> #include <algorithm> typedef long long ll; using namespace std; const int maxn = 5e5 + 5; struct edge { int v, i; }; bool vise[maxn], visvr[maxn]; int nxt[maxn]; vector<edge> g[maxn]; vector<int> e; void dfs(int u) { if (visvr[u]) // cyklus { int i = u; while (visvr[i]) { cout << i + 1 << " "; visvr[i] = false; i = nxt[i]; } cout << "\n"; } visvr[u] = true; while (!g[u].empty()) { edge e = g[u].back(); g[u].pop_back(); if (!vise[e.i]) { vise[e.i] = true; nxt[u] = e.v; dfs(e.v); } } } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; for (int i = 0, a, b; i < m; i++) { cin >> a >> b; a--, b--; g[a].push_back({ b, i }); g[b].push_back({ a, i }); } dfs(0); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...