# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
547280 | 2022-04-10T08:40:37 Z | Jomnoi | Senior Postmen (BOI14_postmen) | C++17 | 128 ms | 262144 KB |
#include <bits/stdc++.h> #define DEBUG 0 using namespace std; const int MAX_N = 5e5 + 10; stack <pair <int, int>> graph[MAX_N]; vector <int> order; bool used[MAX_N], is_print[MAX_N]; int visited[MAX_N]; void dfs(int u) { while(!graph[u].empty()) { auto [v, i] = graph[u].top(); graph[u].pop(); if(used[i] == false) { used[i] = true; dfs(v); } } } int main() { cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; for(int i = 1; i <= m; i++) { int u, v; cin >> u >> v; graph[u].emplace(v, i); graph[v].emplace(u, i); } dfs(1); for(int i = 0; i < order.size(); i++) { if(visited[order[i]] != 0) { int j = i; while(j >= visited[order[i]]) { if(is_print[j] == false) { cout << order[j] << ' '; if(order[i] != order[j]) { visited[order[j]] = 0; } is_print[j] = true; } j--; } cout << '\n'; } else { visited[order[i]] = i + 1; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 107 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 111 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 128 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |