# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
52981 | Bruteforceman | 어르신 집배원 (BOI14_postmen) | C++11 | 1080 ms | 38652 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define prev dfsdf
unordered_set <int> g[500010];
void addEdge(int p, int q) {
g[p].insert(q);
g[q].insert(p);
}
void delEdge(int p, int q) {
g[p].erase(q);
g[q].erase(p);
}
vector <int> tour;
void dfs(int x) {
while (!g[x].empty()){
int i = *g[x].begin();
delEdge(x, i);
dfs(i);
}
tour.push_back(x);
}
bool occ[500010];
int main (int argc, char const* argv[])
{
int n, m;
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; i++) {
g[i].max_load_factor(2048);
g[i].reserve(0.25);
}
for(int i = 0; i < m; i++) {
int p, q;
scanf("%d %d", &p, &q);
addEdge(p, q);
assert(p != q);
}
dfs(1);
vector <int> cycle;
for(int i = 0; i < tour.size(); i++) {
int x = tour[i];
if(occ[x] == false) {
cycle.push_back(x);
occ[x] = true;
} else {
while(cycle.back() != x) {
int node = cycle.back();
printf("%d ", node);
occ[node] = false;
cycle.pop_back();
}
printf("%d\n", x);
}
}
return 0;
}
// 1 5 8 7 5 4 7 6 3 4 8 10 9 2 3 1
컴파일 시 표준 에러 (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... |