Submission #491098

#TimeUsernameProblemLanguageResultExecution timeMemory
491098rainboySegway (COI19_segway)C11
100 / 100
193 ms32852 KiB
#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 20000 #define X 300 #define T 15000 #define INF 0x3f3f3f3f int min(int a, int b) { return a < b ? a : b; } int *ei[T + 1], eo[T + 1]; void append(int t, int i) { int o = eo[t]++; if (o >= 2 && (o & o - 1) == 0) ei[t] = (int *) realloc(ei[t], o * 2 * sizeof *ei[t]); ei[t][o] = i; } int main() { static int ss[N][3], xx[N], yy[N], tt[N], kk[X + 1]; static char accel[X + 1]; int n, m, h, i, x, t, o; scanf("%d", &n); for (i = 0; i < n; i++) for (h = 0; h < 3; h++) scanf("%d", &ss[i][h]); scanf("%d", &m); for (h = 0; h < m; h++) { scanf("%d", &x); accel[x] = 1; } for (t = 0; t <= T; t++) ei[t] = (int *) malloc(2 * sizeof *ei[t]); for (i = 0; i < n; i++) tt[i] = ss[i][0], append(tt[i], i); memset(kk, 0, (X + 1) * sizeof *kk); kk[0] += n; for (t = 0; t <= T; t++) { for (o = eo[t]; o--; ) { i = ei[t][o]; if (xx[i] + 1 < X && accel[xx[i] + 1] && yy[i] <= xx[i] + 1) yy[i] = xx[i] + 1 + kk[xx[i] + 1] % 20; } for (o = eo[t]; o--; ) { i = ei[t][o]; kk[++xx[i]]++; if (xx[i] < X) append(tt[i] = yy[i] <= xx[i] ? t + ss[i][xx[i] / (X / 3)] : t + 1, i); } } for (i = 0; i < n; i++) printf("%d\n", tt[i]); return 0; }

Compilation message (stderr)

segway.c: In function 'append':
segway.c:17:23: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   17 |  if (o >= 2 && (o & o - 1) == 0)
      |                     ~~^~~
segway.c: In function 'main':
segway.c:27:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
segway.c:30:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |    scanf("%d", &ss[i][h]);
      |    ^~~~~~~~~~~~~~~~~~~~~~
segway.c:31:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  scanf("%d", &m);
      |  ^~~~~~~~~~~~~~~
segway.c:33:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   scanf("%d", &x);
      |   ^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...