Submission #485253

#TimeUsernameProblemLanguageResultExecution timeMemory
485253SirCovidThe19thSenior Postmen (BOI14_postmen)C++17
55 / 100
573 ms63988 KiB
#include <bits/stdc++.h> using namespace std; const int mx = 5e5 + 5; int n, m, pth[mx]; bool vis[mx], useEdg[mx]; vector<pair<int, int>> adj[mx]; void dfs(int cur){ if (vis[cur]){ int cyc = cur; while (vis[cyc]){ cout<<cyc<<" "; vis[cyc] = 0; cyc = pth[cyc]; } cout<<endl; } while (adj[cur].size()){ int nxt, ind; tie(nxt, ind) = adj[cur].back(); adj[cur].pop_back(); if (!useEdg[ind]){ useEdg[ind] = vis[cur] = 1; pth[cur] = nxt; dfs(nxt); } } } int main(){ cin >> n >> m; for (int i = 1; i <= m; i++){ int a, b; cin >> a >> b; adj[a].push_back({b, i}); adj[b].push_back({a, i}); } dfs(1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...