#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
const int D = 1000;
int N, Q, X[100005], Y[100005], dist[4 * D + 5][4 * D + 5], dr[] = {-1, 0, 0, 1}, dc[] = {0, -1, 1, 0}, ans[4000005];
queue<ii> qu;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N >> Q;
for (int i = 0; i <= 4 * D; i++) {
for (int j = 0; j <= 4 * D; j++) {
dist[i][j] = (int)1e9;
}
}
for (int i = 1; i <= N; i++) {
cin >> X[i] >> Y[i];
X[i] += 2 * D;
Y[i] += 2 * D;
dist[X[i]][Y[i]] = 0;
qu.emplace(X[i], Y[i]);
}
while (!qu.empty()) {
auto [r, c] = qu.front();
qu.pop();
for (int k = 0; k < 4; k++) {
int nr = r + dr[k], nc = c + dc[k];
if (0 <= nr && nr <= 4 * D && 0 <= nc && nc <= 4 * D) {
if (dist[nr][nc] > dist[r][c] + 1) {
dist[nr][nc] = dist[r][c] + 1;
qu.emplace(nr, nc);
}
}
}
}
for (int i = 0; i <= 4 * D; i++) {
for (int j = 0; j <= 4 * D; j++) {
ans[dist[i][j]]++;
}
}
for (int i = 1, t; i <= Q; i++) {
cin >> t;
cout << ans[t] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
442 ms |
63184 KB |
Output is correct |
2 |
Correct |
447 ms |
63104 KB |
Output is correct |
3 |
Correct |
472 ms |
63220 KB |
Output is correct |
4 |
Correct |
443 ms |
63108 KB |
Output is correct |
5 |
Correct |
440 ms |
63108 KB |
Output is correct |
6 |
Correct |
470 ms |
63096 KB |
Output is correct |
7 |
Correct |
482 ms |
63104 KB |
Output is correct |
8 |
Correct |
439 ms |
63204 KB |
Output is correct |
9 |
Correct |
414 ms |
63104 KB |
Output is correct |
10 |
Correct |
422 ms |
63160 KB |
Output is correct |
11 |
Correct |
456 ms |
63124 KB |
Output is correct |
12 |
Correct |
436 ms |
63116 KB |
Output is correct |
13 |
Correct |
437 ms |
63120 KB |
Output is correct |
14 |
Correct |
424 ms |
63104 KB |
Output is correct |
15 |
Correct |
462 ms |
63124 KB |
Output is correct |
16 |
Correct |
430 ms |
63112 KB |
Output is correct |
17 |
Correct |
451 ms |
63212 KB |
Output is correct |
18 |
Correct |
543 ms |
63100 KB |
Output is correct |
19 |
Correct |
459 ms |
63108 KB |
Output is correct |
20 |
Correct |
412 ms |
63120 KB |
Output is correct |
21 |
Correct |
430 ms |
63052 KB |
Output is correct |
22 |
Correct |
434 ms |
63128 KB |
Output is correct |
23 |
Correct |
578 ms |
63100 KB |
Output is correct |
24 |
Correct |
427 ms |
63056 KB |
Output is correct |
25 |
Correct |
441 ms |
63052 KB |
Output is correct |
26 |
Correct |
451 ms |
63064 KB |
Output is correct |
27 |
Correct |
435 ms |
63168 KB |
Output is correct |
28 |
Correct |
431 ms |
63052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
442 ms |
63184 KB |
Output is correct |
2 |
Correct |
447 ms |
63104 KB |
Output is correct |
3 |
Correct |
472 ms |
63220 KB |
Output is correct |
4 |
Correct |
443 ms |
63108 KB |
Output is correct |
5 |
Correct |
440 ms |
63108 KB |
Output is correct |
6 |
Correct |
470 ms |
63096 KB |
Output is correct |
7 |
Correct |
482 ms |
63104 KB |
Output is correct |
8 |
Correct |
439 ms |
63204 KB |
Output is correct |
9 |
Correct |
414 ms |
63104 KB |
Output is correct |
10 |
Correct |
422 ms |
63160 KB |
Output is correct |
11 |
Correct |
456 ms |
63124 KB |
Output is correct |
12 |
Correct |
436 ms |
63116 KB |
Output is correct |
13 |
Correct |
437 ms |
63120 KB |
Output is correct |
14 |
Correct |
424 ms |
63104 KB |
Output is correct |
15 |
Correct |
462 ms |
63124 KB |
Output is correct |
16 |
Correct |
430 ms |
63112 KB |
Output is correct |
17 |
Correct |
451 ms |
63212 KB |
Output is correct |
18 |
Correct |
543 ms |
63100 KB |
Output is correct |
19 |
Correct |
459 ms |
63108 KB |
Output is correct |
20 |
Correct |
412 ms |
63120 KB |
Output is correct |
21 |
Correct |
430 ms |
63052 KB |
Output is correct |
22 |
Correct |
434 ms |
63128 KB |
Output is correct |
23 |
Correct |
578 ms |
63100 KB |
Output is correct |
24 |
Correct |
427 ms |
63056 KB |
Output is correct |
25 |
Correct |
441 ms |
63052 KB |
Output is correct |
26 |
Correct |
451 ms |
63064 KB |
Output is correct |
27 |
Correct |
435 ms |
63168 KB |
Output is correct |
28 |
Correct |
431 ms |
63052 KB |
Output is correct |
29 |
Correct |
424 ms |
63108 KB |
Output is correct |
30 |
Correct |
416 ms |
63116 KB |
Output is correct |
31 |
Correct |
474 ms |
63116 KB |
Output is correct |
32 |
Correct |
434 ms |
66644 KB |
Output is correct |
33 |
Correct |
438 ms |
63068 KB |
Output is correct |
34 |
Correct |
441 ms |
63132 KB |
Output is correct |
35 |
Correct |
438 ms |
63128 KB |
Output is correct |
36 |
Correct |
432 ms |
63212 KB |
Output is correct |
37 |
Correct |
543 ms |
63240 KB |
Output is correct |
38 |
Correct |
420 ms |
63384 KB |
Output is correct |
39 |
Correct |
450 ms |
64152 KB |
Output is correct |
40 |
Correct |
455 ms |
67068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
79 ms |
127664 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
79 ms |
127664 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
86 ms |
127552 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
86 ms |
127552 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
442 ms |
63184 KB |
Output is correct |
2 |
Correct |
447 ms |
63104 KB |
Output is correct |
3 |
Correct |
472 ms |
63220 KB |
Output is correct |
4 |
Correct |
443 ms |
63108 KB |
Output is correct |
5 |
Correct |
440 ms |
63108 KB |
Output is correct |
6 |
Correct |
470 ms |
63096 KB |
Output is correct |
7 |
Correct |
482 ms |
63104 KB |
Output is correct |
8 |
Correct |
439 ms |
63204 KB |
Output is correct |
9 |
Correct |
414 ms |
63104 KB |
Output is correct |
10 |
Correct |
422 ms |
63160 KB |
Output is correct |
11 |
Correct |
456 ms |
63124 KB |
Output is correct |
12 |
Correct |
436 ms |
63116 KB |
Output is correct |
13 |
Correct |
437 ms |
63120 KB |
Output is correct |
14 |
Correct |
424 ms |
63104 KB |
Output is correct |
15 |
Correct |
462 ms |
63124 KB |
Output is correct |
16 |
Correct |
430 ms |
63112 KB |
Output is correct |
17 |
Correct |
451 ms |
63212 KB |
Output is correct |
18 |
Correct |
543 ms |
63100 KB |
Output is correct |
19 |
Correct |
459 ms |
63108 KB |
Output is correct |
20 |
Correct |
412 ms |
63120 KB |
Output is correct |
21 |
Correct |
430 ms |
63052 KB |
Output is correct |
22 |
Correct |
434 ms |
63128 KB |
Output is correct |
23 |
Correct |
578 ms |
63100 KB |
Output is correct |
24 |
Correct |
427 ms |
63056 KB |
Output is correct |
25 |
Correct |
441 ms |
63052 KB |
Output is correct |
26 |
Correct |
451 ms |
63064 KB |
Output is correct |
27 |
Correct |
435 ms |
63168 KB |
Output is correct |
28 |
Correct |
431 ms |
63052 KB |
Output is correct |
29 |
Correct |
424 ms |
63108 KB |
Output is correct |
30 |
Correct |
416 ms |
63116 KB |
Output is correct |
31 |
Correct |
474 ms |
63116 KB |
Output is correct |
32 |
Correct |
434 ms |
66644 KB |
Output is correct |
33 |
Correct |
438 ms |
63068 KB |
Output is correct |
34 |
Correct |
441 ms |
63132 KB |
Output is correct |
35 |
Correct |
438 ms |
63128 KB |
Output is correct |
36 |
Correct |
432 ms |
63212 KB |
Output is correct |
37 |
Correct |
543 ms |
63240 KB |
Output is correct |
38 |
Correct |
420 ms |
63384 KB |
Output is correct |
39 |
Correct |
450 ms |
64152 KB |
Output is correct |
40 |
Correct |
455 ms |
67068 KB |
Output is correct |
41 |
Runtime error |
79 ms |
127664 KB |
Execution killed with signal 11 |
42 |
Halted |
0 ms |
0 KB |
- |