Submission #1116449

#TimeUsernameProblemLanguageResultExecution timeMemory
1116449gustavo_dSenior Postmen (BOI14_postmen)C++17
55 / 100
547 ms80052 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e5; struct Edge { int v, id; Edge(int _v=0, int _id=0): v(_v), id(_id) {} }; vector<Edge> adj[MAXN]; bool mark[MAXN]; bool in_eulerian[MAXN]; vector<int> eulerian; void dfs(int v) { while (!adj[v].empty()) { Edge ed = adj[v].back(); adj[v].pop_back(); if (mark[ed.id]) continue; mark[ed.id] = true; dfs(ed.v); } if (in_eulerian[v]) { int i = -1; while (i != v) { i = eulerian.back(); eulerian.pop_back(); in_eulerian[i] = false; cout << i+1 << ' '; } cout << endl; } in_eulerian[v] = true; eulerian.push_back(v); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; for (int i=0; i<m; i++) { int u, v; cin >> u >> v; u--; v--; adj[u].push_back(Edge(v, i)); adj[v].push_back(Edge(u, i)); } for (int i=0; i<n; i++) { if (!adj[i].empty()) dfs(i); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...