# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
941017 | 2024-03-08T05:12:07 Z | KaleemRazaSyed | Senior Postmen (BOI14_postmen) | C++17 | 6 ms | 12888 KB |
#include<iostream> #include<vector> using namespace std; const int N = 5e5+5; struct edge { int u, v; bool vis; int other(int x) { return u + v - x; } }; vector<int> G[N]; vector<edge> e; vector<int> p; void dfs(int v) { p.push_back(v); while(G[v].size()) { int i = G[v].back(); G[v].pop_back(); if(e[i].vis) continue; e[i].vis = true; dfs(e[i].other(v)); } } bool seen[N]; int main() { int n, m; cin >> n >> m; for(int i = 0; i < m; i ++) { int u, v; cin >> u >> v; G[u].push_back(i); G[v].push_back(i); e.push_back(edge{u, v, false}); } dfs(1); vector<int> ans; for(int i = 0; i < p.size(); i++) { if(!seen[p[i]]) ans.push_back(p[i]); else { cout << p[i]; while(ans.back() != p[i]) { cout <<' ' << ans.back(); seen[ans.back()] = false; ans.pop_back(); } cout << '\n'; } seen[p[i]] = true; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 12376 KB | Output is correct |
2 | Correct | 3 ms | 12380 KB | Output is correct |
3 | Correct | 3 ms | 12380 KB | Output is correct |
4 | Correct | 6 ms | 12636 KB | Output is correct |
5 | Incorrect | 4 ms | 12380 KB | Some edges were not used |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 12380 KB | Output is correct |
2 | Correct | 4 ms | 12380 KB | Output is correct |
3 | Correct | 3 ms | 12380 KB | Output is correct |
4 | Correct | 5 ms | 12636 KB | Output is correct |
5 | Incorrect | 4 ms | 12380 KB | Some edges were not used |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 12376 KB | Output is correct |
2 | Correct | 4 ms | 12888 KB | Output is correct |
3 | Correct | 3 ms | 12376 KB | Output is correct |
4 | Correct | 5 ms | 12636 KB | Output is correct |
5 | Incorrect | 3 ms | 12380 KB | Some edges were not used |
6 | Halted | 0 ms | 0 KB | - |