# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
491098 |
2021-11-30T14:22:02 Z |
rainboy |
Segway (COI19_segway) |
C |
|
193 ms |
32852 KB |
#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
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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
844 KB |
Output is correct |
2 |
Correct |
3 ms |
1228 KB |
Output is correct |
3 |
Correct |
9 ms |
2252 KB |
Output is correct |
4 |
Correct |
27 ms |
5972 KB |
Output is correct |
5 |
Correct |
193 ms |
32852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
844 KB |
Output is correct |
2 |
Correct |
1 ms |
796 KB |
Output is correct |
3 |
Correct |
1 ms |
844 KB |
Output is correct |
4 |
Correct |
1 ms |
844 KB |
Output is correct |
5 |
Correct |
1 ms |
844 KB |
Output is correct |
6 |
Correct |
2 ms |
972 KB |
Output is correct |
7 |
Correct |
3 ms |
972 KB |
Output is correct |
8 |
Correct |
3 ms |
1100 KB |
Output is correct |
9 |
Correct |
3 ms |
1228 KB |
Output is correct |
10 |
Correct |
5 ms |
1356 KB |
Output is correct |
11 |
Correct |
2 ms |
1228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
844 KB |
Output is correct |
2 |
Correct |
3 ms |
1228 KB |
Output is correct |
3 |
Correct |
9 ms |
2252 KB |
Output is correct |
4 |
Correct |
27 ms |
5972 KB |
Output is correct |
5 |
Correct |
193 ms |
32852 KB |
Output is correct |
6 |
Correct |
1 ms |
844 KB |
Output is correct |
7 |
Correct |
1 ms |
796 KB |
Output is correct |
8 |
Correct |
1 ms |
844 KB |
Output is correct |
9 |
Correct |
1 ms |
844 KB |
Output is correct |
10 |
Correct |
1 ms |
844 KB |
Output is correct |
11 |
Correct |
2 ms |
972 KB |
Output is correct |
12 |
Correct |
3 ms |
972 KB |
Output is correct |
13 |
Correct |
3 ms |
1100 KB |
Output is correct |
14 |
Correct |
3 ms |
1228 KB |
Output is correct |
15 |
Correct |
5 ms |
1356 KB |
Output is correct |
16 |
Correct |
2 ms |
1228 KB |
Output is correct |
17 |
Correct |
9 ms |
2508 KB |
Output is correct |
18 |
Correct |
15 ms |
4280 KB |
Output is correct |
19 |
Correct |
69 ms |
14932 KB |
Output is correct |
20 |
Correct |
94 ms |
19724 KB |
Output is correct |
21 |
Correct |
114 ms |
23604 KB |
Output is correct |
22 |
Correct |
153 ms |
28188 KB |
Output is correct |
23 |
Correct |
135 ms |
26208 KB |
Output is correct |