# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
11146 | tncks0121 | 어르신 집배원 (BOI14_postmen) | C++14 | 1084 ms | 36844 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//
// main.cpp
// BOI14_postmen
//
// Created by 박수찬 on 14. 11. 14..
// Copyright (c) 2014년 박수찬. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <list>
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
const int N_ = 500050, M_ = 500050;
int N, M;
list<int> gph[N_];
list<int> edge[N_];
bool passed[M_];
bool visited[N_];
typedef list<int>::iterator lit;
int main() {
scanf("%d%d", &N, &M);
for(int i = 1; i <= M; i++) {
int u, v; scanf("%d%d", &u, &v);
gph[u].push_back(v);
gph[v].push_back(u);
edge[u].push_back(i);
edge[v].push_back(i);
}
for(int u = 1; u <= N; u++) {
stack<int> stk; stk.push(u);
while(!stk.empty()) {
int cur = stk.top();
visited[cur] = true;
bool updated = false;
for(auto it = gph[cur].begin(), it2 = edge[cur].begin(); it != gph[cur].end(); it++, it2++) {
int nxt = *it;
int e = *it2; if(passed[e]) continue;
passed[e] = true;
if(visited[nxt]) {
while(!stk.empty() && stk.top() != nxt) {
int vt = stk.top(); stk.pop();
visited[vt] = false;
printf("%d ", vt);
}
printf("%d\n", nxt);
} else {
stk.push(nxt);
}
updated = true;
break;
}
if(!updated && !stk.empty()) stk.pop();
}
}
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... |