#include <stdio.h>
#define N 100000
#define X 2000
#define T 1000
int min(int a, int b) { return a < b ? a : b; }
int main() {
static int xx[N], yy[N], nn[T + 1];
static int dd[X * 2 + 1][X * 2 + 1];
int n, q, i, t, x, y;
scanf("%d%d", &n, &q);
for (x = 0; x <= X * 2; x++)
for (y = 0; y <= X * 2; y++)
dd[x][y] = T + 1;
for (i = 0; i < n; i++) {
scanf("%d%d", &xx[i], &yy[i]);
dd[X + xx[i]][X + yy[i]] = 0;
}
for (x = 0; x <= X * 2; x++) {
for (y = 1; y <= X * 2; y++)
dd[x][y] = min(dd[x][y], dd[x][y - 1] + 1);
for (y = X * 2 - 1; y >= 0; y--)
dd[x][y] = min(dd[x][y], dd[x][y + 1] + 1);
}
for (y = 0; y <= X * 2; y++) {
for (x = 1; x <= X * 2; x++)
dd[x][y] = min(dd[x][y], dd[x - 1][y] + 1);
for (x = X * 2 - 1; x >= 0; x--)
dd[x][y] = min(dd[x][y], dd[x + 1][y] + 1);
}
for (x = 0; x <= X * 2; x++)
for (y = 0; y <= X * 2; y++)
if (dd[x][y] <= T)
nn[dd[x][y]]++;
while (q--) {
scanf("%d", &t);
printf("%d\n", nn[t]);
}
return 0;
}
Compilation message
cell.c: In function 'main':
cell.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | scanf("%d%d", &n, &q);
| ^~~~~~~~~~~~~~~~~~~~~
cell.c:19:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
19 | scanf("%d%d", &xx[i], &yy[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cell.c:39:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | scanf("%d", &t);
| ^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
485 ms |
62928 KB |
Output is correct |
2 |
Correct |
488 ms |
62932 KB |
Output is correct |
3 |
Correct |
461 ms |
62932 KB |
Output is correct |
4 |
Correct |
480 ms |
62928 KB |
Output is correct |
5 |
Correct |
481 ms |
62928 KB |
Output is correct |
6 |
Correct |
475 ms |
62924 KB |
Output is correct |
7 |
Correct |
473 ms |
62932 KB |
Output is correct |
8 |
Correct |
475 ms |
62904 KB |
Output is correct |
9 |
Correct |
480 ms |
62932 KB |
Output is correct |
10 |
Correct |
473 ms |
62928 KB |
Output is correct |
11 |
Correct |
487 ms |
62928 KB |
Output is correct |
12 |
Correct |
477 ms |
62932 KB |
Output is correct |
13 |
Correct |
472 ms |
62952 KB |
Output is correct |
14 |
Correct |
482 ms |
63044 KB |
Output is correct |
15 |
Correct |
481 ms |
62932 KB |
Output is correct |
16 |
Correct |
478 ms |
63052 KB |
Output is correct |
17 |
Correct |
473 ms |
62924 KB |
Output is correct |
18 |
Correct |
481 ms |
63012 KB |
Output is correct |
19 |
Correct |
472 ms |
62928 KB |
Output is correct |
20 |
Correct |
481 ms |
62924 KB |
Output is correct |
21 |
Correct |
471 ms |
62936 KB |
Output is correct |
22 |
Correct |
482 ms |
62932 KB |
Output is correct |
23 |
Correct |
475 ms |
62924 KB |
Output is correct |
24 |
Correct |
471 ms |
62932 KB |
Output is correct |
25 |
Correct |
469 ms |
62932 KB |
Output is correct |
26 |
Correct |
491 ms |
62932 KB |
Output is correct |
27 |
Correct |
484 ms |
62924 KB |
Output is correct |
28 |
Correct |
460 ms |
62932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
485 ms |
62928 KB |
Output is correct |
2 |
Correct |
488 ms |
62932 KB |
Output is correct |
3 |
Correct |
461 ms |
62932 KB |
Output is correct |
4 |
Correct |
480 ms |
62928 KB |
Output is correct |
5 |
Correct |
481 ms |
62928 KB |
Output is correct |
6 |
Correct |
475 ms |
62924 KB |
Output is correct |
7 |
Correct |
473 ms |
62932 KB |
Output is correct |
8 |
Correct |
475 ms |
62904 KB |
Output is correct |
9 |
Correct |
480 ms |
62932 KB |
Output is correct |
10 |
Correct |
473 ms |
62928 KB |
Output is correct |
11 |
Correct |
487 ms |
62928 KB |
Output is correct |
12 |
Correct |
477 ms |
62932 KB |
Output is correct |
13 |
Correct |
472 ms |
62952 KB |
Output is correct |
14 |
Correct |
482 ms |
63044 KB |
Output is correct |
15 |
Correct |
481 ms |
62932 KB |
Output is correct |
16 |
Correct |
478 ms |
63052 KB |
Output is correct |
17 |
Correct |
473 ms |
62924 KB |
Output is correct |
18 |
Correct |
481 ms |
63012 KB |
Output is correct |
19 |
Correct |
472 ms |
62928 KB |
Output is correct |
20 |
Correct |
481 ms |
62924 KB |
Output is correct |
21 |
Correct |
471 ms |
62936 KB |
Output is correct |
22 |
Correct |
482 ms |
62932 KB |
Output is correct |
23 |
Correct |
475 ms |
62924 KB |
Output is correct |
24 |
Correct |
471 ms |
62932 KB |
Output is correct |
25 |
Correct |
469 ms |
62932 KB |
Output is correct |
26 |
Correct |
491 ms |
62932 KB |
Output is correct |
27 |
Correct |
484 ms |
62924 KB |
Output is correct |
28 |
Correct |
460 ms |
62932 KB |
Output is correct |
29 |
Correct |
474 ms |
63008 KB |
Output is correct |
30 |
Correct |
467 ms |
62932 KB |
Output is correct |
31 |
Correct |
479 ms |
62932 KB |
Output is correct |
32 |
Correct |
490 ms |
63700 KB |
Output is correct |
33 |
Correct |
475 ms |
62928 KB |
Output is correct |
34 |
Correct |
480 ms |
62924 KB |
Output is correct |
35 |
Correct |
470 ms |
62932 KB |
Output is correct |
36 |
Correct |
479 ms |
62928 KB |
Output is correct |
37 |
Correct |
473 ms |
62892 KB |
Output is correct |
38 |
Correct |
477 ms |
62936 KB |
Output is correct |
39 |
Correct |
482 ms |
63004 KB |
Output is correct |
40 |
Correct |
542 ms |
63792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
97 ms |
127352 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
97 ms |
127352 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
94 ms |
127412 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
94 ms |
127412 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
485 ms |
62928 KB |
Output is correct |
2 |
Correct |
488 ms |
62932 KB |
Output is correct |
3 |
Correct |
461 ms |
62932 KB |
Output is correct |
4 |
Correct |
480 ms |
62928 KB |
Output is correct |
5 |
Correct |
481 ms |
62928 KB |
Output is correct |
6 |
Correct |
475 ms |
62924 KB |
Output is correct |
7 |
Correct |
473 ms |
62932 KB |
Output is correct |
8 |
Correct |
475 ms |
62904 KB |
Output is correct |
9 |
Correct |
480 ms |
62932 KB |
Output is correct |
10 |
Correct |
473 ms |
62928 KB |
Output is correct |
11 |
Correct |
487 ms |
62928 KB |
Output is correct |
12 |
Correct |
477 ms |
62932 KB |
Output is correct |
13 |
Correct |
472 ms |
62952 KB |
Output is correct |
14 |
Correct |
482 ms |
63044 KB |
Output is correct |
15 |
Correct |
481 ms |
62932 KB |
Output is correct |
16 |
Correct |
478 ms |
63052 KB |
Output is correct |
17 |
Correct |
473 ms |
62924 KB |
Output is correct |
18 |
Correct |
481 ms |
63012 KB |
Output is correct |
19 |
Correct |
472 ms |
62928 KB |
Output is correct |
20 |
Correct |
481 ms |
62924 KB |
Output is correct |
21 |
Correct |
471 ms |
62936 KB |
Output is correct |
22 |
Correct |
482 ms |
62932 KB |
Output is correct |
23 |
Correct |
475 ms |
62924 KB |
Output is correct |
24 |
Correct |
471 ms |
62932 KB |
Output is correct |
25 |
Correct |
469 ms |
62932 KB |
Output is correct |
26 |
Correct |
491 ms |
62932 KB |
Output is correct |
27 |
Correct |
484 ms |
62924 KB |
Output is correct |
28 |
Correct |
460 ms |
62932 KB |
Output is correct |
29 |
Correct |
474 ms |
63008 KB |
Output is correct |
30 |
Correct |
467 ms |
62932 KB |
Output is correct |
31 |
Correct |
479 ms |
62932 KB |
Output is correct |
32 |
Correct |
490 ms |
63700 KB |
Output is correct |
33 |
Correct |
475 ms |
62928 KB |
Output is correct |
34 |
Correct |
480 ms |
62924 KB |
Output is correct |
35 |
Correct |
470 ms |
62932 KB |
Output is correct |
36 |
Correct |
479 ms |
62928 KB |
Output is correct |
37 |
Correct |
473 ms |
62892 KB |
Output is correct |
38 |
Correct |
477 ms |
62936 KB |
Output is correct |
39 |
Correct |
482 ms |
63004 KB |
Output is correct |
40 |
Correct |
542 ms |
63792 KB |
Output is correct |
41 |
Runtime error |
97 ms |
127352 KB |
Execution killed with signal 11 |
42 |
Halted |
0 ms |
0 KB |
- |