제출 #527550

#제출 시각아이디문제언어결과실행 시간메모리
527550rainboy스파이 (JOI13_spy)C11
100 / 100
211 ms20892 KiB
#include <stdio.h> #include <stdlib.h> #define N 2000 void append(int **ej, int *eo, int i, int j) { int o = eo[i]++; if (o >= 2 && (o & o - 1) == 0) ej[i] = (int *) realloc(ej[i], o * 2 * sizeof *ej[i]); ej[i][o] = j; } int time; void dfs(int **ej, int *eo, int *ta, int *tb, int i) { int o; ta[i] = time++; for (o = eo[i]; o--; ) { int j = ej[i][o]; dfs(ej, eo, ta, tb, j); } tb[i] = time; } int main() { static int *ej[2][N], eo[2][N], rr[2], ta[2][N], tb[2][N], aa[N + 1][N + 1]; int n, m, h, i, j; scanf("%d%d", &n, &m); for (h = 0; h < 2; h++) for (i = 0; i < n; i++) ej[h][i] = (int *) malloc(2 * sizeof *ej[h][i]); for (j = 0; j < n; j++) for (h = 0; h < 2; h++) { scanf("%d", &i), i--; if (i == -1) rr[h] = j; else append(ej[h], eo[h], i, j); } for (h = 0; h < 2; h++) time = 0, dfs(ej[h], eo[h], ta[h], tb[h], rr[h]); while (m--) { scanf("%d%d", &i, &j), i--, j--; aa[ta[0][i]][ta[1][j]]++, aa[ta[0][i]][tb[1][j]]--; aa[tb[0][i]][ta[1][j]]--, aa[tb[0][i]][tb[1][j]]++; } for (i = 0; i < n; i++) for (j = 1; j < n; j++) aa[i][j] += aa[i][j - 1]; for (j = 0; j < n; j++) for (i = 1; i < n; i++) aa[i][j] += aa[i - 1][j]; for (i = 0; i < n; i++) printf("%d\n", aa[ta[0][i]][ta[1][i]]); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

spy.c: In function 'append':
spy.c:9:23: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
    9 |  if (o >= 2 && (o & o - 1) == 0)
      |                     ~~^~~
spy.c: In function 'main':
spy.c:32:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
spy.c:38:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |    scanf("%d", &i), i--;
      |    ^~~~~~~~~~~~~~~
spy.c:47:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |   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...