# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
109013 | 2019-05-04T02:32:23 Z | thebes | Senior Postmen (BOI14_postmen) | C++14 | 14 ms | 12160 KB |
#include <bits/stdc++.h> using namespace std; const int MN = 5e5+5; int mo[MN], f, n, m, i, x, y, st[MN]; vector<pair<int,int>> adj[MN]; stack<pair<int,int>> s; void dfs(int n,int p){ st[n] = 1; s.push({n,p}); for(auto v : adj[n]){ if(v.second==p||mo[v.second]) continue; mo[v.second]=1; if(st[v.first]){ f = 1; mo[v.second]=1; printf("%d ",v.first); while(s.size()&&s.top().first!=v.first){ mo[s.top().second]=1; printf("%d ",s.top().first); s.pop(); } printf("\n"); } else dfs(v.first, v.second); if(f) break; else mo[v.second]=0; } if(s.size()&&s.top().first==n) s.pop(); st[n] = 0; } int main(){ for(scanf("%d%d",&n,&m),i=1;i<=m;i++){ scanf("%d%d",&x,&y); adj[x].push_back({y,i}); adj[y].push_back({x,i}); } i=1; while(i<=n){ f=0; dfs(i,-1); if(!f) i++; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 12160 KB | Output is correct |
2 | Incorrect | 12 ms | 12124 KB | Some edges were not used |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 12160 KB | Output is correct |
2 | Incorrect | 13 ms | 12160 KB | Some edges were not used |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 12032 KB | Output is correct |
2 | Incorrect | 12 ms | 12032 KB | Some edges were not used |
3 | Halted | 0 ms | 0 KB | - |