# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103583 | 2019-03-31T18:55:31 Z | luciocf | Senior Postmen (BOI14_postmen) | C++14 | 60 ms | 48120 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5+10; typedef pair<int, int> pii; int qtd; bool markEdge[maxn], mark[maxn]; vector<pii> grafo[maxn]; vector<int> ans[maxn]; stack<pii> stk; void dfs(int u) { if (mark[u]) { ++qtd; ans[qtd].push_back(u); while (true) { int v = stk.top().first; stk.pop(); mark[v] = 0; if (v == u) break; ans[qtd].push_back(v); } } mark[u] = 1; for (auto v: grafo[u]) { if (!markEdge[v.second]) { stk.push({u, v.first}); markEdge[v.second] = 1; dfs(v.first); } } } int main(void) { int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= m; i++) { int u, v; scanf("%d %d", &u, &v); grafo[u].push_back({v, i}); grafo[v].push_back({u, i}); } dfs(1); ++qtd; while (stk.size() > 0) { int v = stk.top().first; stk.pop(); ans[qtd].push_back(v); } for (int i = 1; i <= qtd; i++) { printf("%d", ans[i][0]); for (int j = 1; j < ans[i].size(); j++) printf(" %d", ans[i][j]); printf("\n"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 60 ms | 48096 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 45 ms | 48120 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 48 ms | 48076 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |