# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
109016 | 2019-05-04T02:50:55 Z | thebes | 어르신 집배원 (BOI14_postmen) | C++14 | 500 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], rt; 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(f) break; if(v.second==p||mo[v.second]) continue; if(st[v.first]&&v.first==rt){ f = 1; mo[v.second]=1; while(s.size()){ mo[s.top().second]=1; printf("%d ",s.top().first); s.pop(); } printf("\n"); } else if(!st[v.first]) dfs(v.first, v.second); if(f) break; } 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; rt=i; dfs(i,0); if(!f) i++; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 12160 KB | Output is correct |
2 | Correct | 11 ms | 12032 KB | Output is correct |
3 | Correct | 11 ms | 12160 KB | Output is correct |
4 | Correct | 15 ms | 12160 KB | Output is correct |
5 | Execution timed out | 1086 ms | 12032 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 12032 KB | Output is correct |
2 | Correct | 14 ms | 12032 KB | Output is correct |
3 | Correct | 14 ms | 12044 KB | Output is correct |
4 | Correct | 20 ms | 12160 KB | Output is correct |
5 | Execution timed out | 1079 ms | 12160 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 12032 KB | Output is correct |
2 | Correct | 12 ms | 12160 KB | Output is correct |
3 | Correct | 14 ms | 12080 KB | Output is correct |
4 | Correct | 14 ms | 12160 KB | Output is correct |
5 | Execution timed out | 1086 ms | 12160 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |