제출 #544617

#제출 시각아이디문제언어결과실행 시간메모리
544617rainboy어르신 집배원 (BOI14_postmen)C11
100 / 100
374 ms68016 KiB
#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) 메시지

postmen.c: In function 'link':
postmen.c:13:23: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   13 |  if (o >= 2 && (o & o - 1) == 0)
      |                     ~~^~~
postmen.c: In function 'main':
postmen.c:34:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
postmen.c:38:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |   scanf("%d%d", &i, &j), i--, j--;
      |   ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...