| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 544617 | rainboy | 어르신 집배원 (BOI14_postmen) | C11 | 374 ms | 68016 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <stdlib.h>
#define N 500000
#define M 500000
int ij[M]; char used[M];
int *oh[N], oo[N];
void link(int i, int h) {
int o = oo[i]++;
if (o >= 2 && (o & o - 1) == 0)
oh[i] = (int *) realloc(oh[i], o * 2 * sizeof *oh[i]);
oh[i][o] = h;
}
int qu[1 + M], cnt;
void dfs(int i) {
while (oo[i]) {
int h = oh[i][--oo[i]];
if (!used[h])
used[h] = 1, dfs(i ^ ij[h]);
}
qu[cnt++] = i;
}
int main() {
static char in[N];
int n, m, h, i, j, cnt_;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++)
oh[i] = (int *) malloc(2 * sizeof *oh[i]);
for (h = 0; h < m; h++) {
scanf("%d%d", &i, &j), i--, j--;
ij[h] = i ^ j;
link(i, h), link(j, h);
}
dfs(0);
cnt_ = 0;
for (h = 0; h < cnt; h++)
if (!in[qu[h]])
in[qu[h]] = 1, qu[cnt_++] = qu[h];
else {
while (qu[cnt_ - 1] != qu[h]) {
printf("%d ", qu[cnt_ - 1] + 1);
in[qu[--cnt_]] = 0;
}
printf("%d\n", qu[h] + 1);
}
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... | ||||
