# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
109015 | thebes | Senior Postmen (BOI14_postmen) | C++14 | 1085 ms | 12160 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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(v.second==p||mo[v.second]) continue;
if(st[v.first]&&v.first==rt){
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 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,-1);
if(!f) i++;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |