#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fi first
#define se second
#define For(i, l, r) for (auto i = (l); i < (r); i++)
#define ForE(i, l, r) for (auto i = (l); i <= (r); i++)
#define FordE(i, l, r) for (auto i = (l); i >= (r); i--)
#define Fora(v, a) for (auto v: (a))
#define bend(a) (a).begin(), (a).end()
#define isz(a) ((signed)(a).size())
using ll = long long;
using ld = long double;
using pii = pair <int, int>;
using vi = vector <int>;
using vpii = vector <pii>;
using vvi = vector <vi>;
const int N = 1e5 + 5, Q = 5e5 + 5;
struct point{
int x, y;
};
int n, q;
point a[N];
int b[Q];
namespace subtask12{
bool check(){
ForE(i, 1, n){
if (not (abs(a[i].x) <= 1000 and abs(a[i].y) <= 1000)){
return false;
}
}
ForE(i, 1, q){
if (not (b[i] <= 1000)){
return false;
}
}
return true;
}
const int N = 4e3 + 5, offset = 2e3;
int dist[N][N];
int ans[N];
vpii dir = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
void solve(){
For(x, 0, N){
For(y, 0, N){
dist[x][y] = -1;
}
}
queue <pii> qu;
ForE(i, 1, n){
a[i].x += offset; a[i].y += offset;
dist[a[i].x][a[i].y] = 0;
qu.emplace(a[i].x, a[i].y);
}
while (not qu.empty()){
auto [x, y] = qu.front(); qu.pop();
ans[dist[x][y]]++;
if (dist[x][y] == N - 1){
break;
}
for (auto [dx, dy]: dir){
int tx = x + dx, ty = y + dy;
if (0 <= tx and tx < N and 0 <= ty and ty < N and dist[tx][ty] == -1){
dist[tx][ty] = dist[x][y] + 1;
qu.emplace(tx, ty);
}
}
}
ForE(i, 1, q){
cout << ans[b[i]] << "\n";
}
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// freopen("KEK.inp", "r", stdin);
// freopen("KEK.out", "w", stdout);
cin >> n >> q;
ForE(i, 1, n){
cin >> a[i].x >> a[i].y;
}
ForE(i, 1, q){
cin >> b[i];
}
if (subtask12::check()){
subtask12::solve();
return 0;
}
}
/*
==================================================+
INPUT |
--------------------------------------------------|
--------------------------------------------------|
==================================================+
OUTPUT |
--------------------------------------------------|
--------------------------------------------------|
==================================================+
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
460 ms |
63168 KB |
Output is correct |
2 |
Correct |
447 ms |
63180 KB |
Output is correct |
3 |
Correct |
436 ms |
63184 KB |
Output is correct |
4 |
Correct |
456 ms |
63176 KB |
Output is correct |
5 |
Correct |
452 ms |
63240 KB |
Output is correct |
6 |
Correct |
463 ms |
63188 KB |
Output is correct |
7 |
Correct |
485 ms |
63168 KB |
Output is correct |
8 |
Correct |
415 ms |
63280 KB |
Output is correct |
9 |
Correct |
488 ms |
63284 KB |
Output is correct |
10 |
Correct |
438 ms |
63180 KB |
Output is correct |
11 |
Correct |
521 ms |
63180 KB |
Output is correct |
12 |
Correct |
457 ms |
63192 KB |
Output is correct |
13 |
Correct |
433 ms |
63152 KB |
Output is correct |
14 |
Correct |
454 ms |
63192 KB |
Output is correct |
15 |
Correct |
441 ms |
63192 KB |
Output is correct |
16 |
Correct |
442 ms |
63172 KB |
Output is correct |
17 |
Correct |
412 ms |
63184 KB |
Output is correct |
18 |
Correct |
473 ms |
63240 KB |
Output is correct |
19 |
Correct |
429 ms |
63264 KB |
Output is correct |
20 |
Correct |
410 ms |
63172 KB |
Output is correct |
21 |
Correct |
477 ms |
63292 KB |
Output is correct |
22 |
Correct |
439 ms |
63172 KB |
Output is correct |
23 |
Correct |
414 ms |
63172 KB |
Output is correct |
24 |
Correct |
408 ms |
63160 KB |
Output is correct |
25 |
Correct |
437 ms |
63256 KB |
Output is correct |
26 |
Correct |
437 ms |
63180 KB |
Output is correct |
27 |
Correct |
487 ms |
63188 KB |
Output is correct |
28 |
Correct |
430 ms |
63060 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
460 ms |
63168 KB |
Output is correct |
2 |
Correct |
447 ms |
63180 KB |
Output is correct |
3 |
Correct |
436 ms |
63184 KB |
Output is correct |
4 |
Correct |
456 ms |
63176 KB |
Output is correct |
5 |
Correct |
452 ms |
63240 KB |
Output is correct |
6 |
Correct |
463 ms |
63188 KB |
Output is correct |
7 |
Correct |
485 ms |
63168 KB |
Output is correct |
8 |
Correct |
415 ms |
63280 KB |
Output is correct |
9 |
Correct |
488 ms |
63284 KB |
Output is correct |
10 |
Correct |
438 ms |
63180 KB |
Output is correct |
11 |
Correct |
521 ms |
63180 KB |
Output is correct |
12 |
Correct |
457 ms |
63192 KB |
Output is correct |
13 |
Correct |
433 ms |
63152 KB |
Output is correct |
14 |
Correct |
454 ms |
63192 KB |
Output is correct |
15 |
Correct |
441 ms |
63192 KB |
Output is correct |
16 |
Correct |
442 ms |
63172 KB |
Output is correct |
17 |
Correct |
412 ms |
63184 KB |
Output is correct |
18 |
Correct |
473 ms |
63240 KB |
Output is correct |
19 |
Correct |
429 ms |
63264 KB |
Output is correct |
20 |
Correct |
410 ms |
63172 KB |
Output is correct |
21 |
Correct |
477 ms |
63292 KB |
Output is correct |
22 |
Correct |
439 ms |
63172 KB |
Output is correct |
23 |
Correct |
414 ms |
63172 KB |
Output is correct |
24 |
Correct |
408 ms |
63160 KB |
Output is correct |
25 |
Correct |
437 ms |
63256 KB |
Output is correct |
26 |
Correct |
437 ms |
63180 KB |
Output is correct |
27 |
Correct |
487 ms |
63188 KB |
Output is correct |
28 |
Correct |
430 ms |
63060 KB |
Output is correct |
29 |
Correct |
428 ms |
63180 KB |
Output is correct |
30 |
Correct |
438 ms |
63092 KB |
Output is correct |
31 |
Correct |
421 ms |
63176 KB |
Output is correct |
32 |
Correct |
453 ms |
66404 KB |
Output is correct |
33 |
Correct |
434 ms |
63176 KB |
Output is correct |
34 |
Correct |
443 ms |
63396 KB |
Output is correct |
35 |
Correct |
427 ms |
63192 KB |
Output is correct |
36 |
Correct |
409 ms |
63172 KB |
Output is correct |
37 |
Correct |
437 ms |
63148 KB |
Output is correct |
38 |
Correct |
412 ms |
63560 KB |
Output is correct |
39 |
Correct |
447 ms |
64192 KB |
Output is correct |
40 |
Correct |
441 ms |
66900 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
1044 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
1044 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
460 ms |
63168 KB |
Output is correct |
2 |
Correct |
447 ms |
63180 KB |
Output is correct |
3 |
Correct |
436 ms |
63184 KB |
Output is correct |
4 |
Correct |
456 ms |
63176 KB |
Output is correct |
5 |
Correct |
452 ms |
63240 KB |
Output is correct |
6 |
Correct |
463 ms |
63188 KB |
Output is correct |
7 |
Correct |
485 ms |
63168 KB |
Output is correct |
8 |
Correct |
415 ms |
63280 KB |
Output is correct |
9 |
Correct |
488 ms |
63284 KB |
Output is correct |
10 |
Correct |
438 ms |
63180 KB |
Output is correct |
11 |
Correct |
521 ms |
63180 KB |
Output is correct |
12 |
Correct |
457 ms |
63192 KB |
Output is correct |
13 |
Correct |
433 ms |
63152 KB |
Output is correct |
14 |
Correct |
454 ms |
63192 KB |
Output is correct |
15 |
Correct |
441 ms |
63192 KB |
Output is correct |
16 |
Correct |
442 ms |
63172 KB |
Output is correct |
17 |
Correct |
412 ms |
63184 KB |
Output is correct |
18 |
Correct |
473 ms |
63240 KB |
Output is correct |
19 |
Correct |
429 ms |
63264 KB |
Output is correct |
20 |
Correct |
410 ms |
63172 KB |
Output is correct |
21 |
Correct |
477 ms |
63292 KB |
Output is correct |
22 |
Correct |
439 ms |
63172 KB |
Output is correct |
23 |
Correct |
414 ms |
63172 KB |
Output is correct |
24 |
Correct |
408 ms |
63160 KB |
Output is correct |
25 |
Correct |
437 ms |
63256 KB |
Output is correct |
26 |
Correct |
437 ms |
63180 KB |
Output is correct |
27 |
Correct |
487 ms |
63188 KB |
Output is correct |
28 |
Correct |
430 ms |
63060 KB |
Output is correct |
29 |
Correct |
428 ms |
63180 KB |
Output is correct |
30 |
Correct |
438 ms |
63092 KB |
Output is correct |
31 |
Correct |
421 ms |
63176 KB |
Output is correct |
32 |
Correct |
453 ms |
66404 KB |
Output is correct |
33 |
Correct |
434 ms |
63176 KB |
Output is correct |
34 |
Correct |
443 ms |
63396 KB |
Output is correct |
35 |
Correct |
427 ms |
63192 KB |
Output is correct |
36 |
Correct |
409 ms |
63172 KB |
Output is correct |
37 |
Correct |
437 ms |
63148 KB |
Output is correct |
38 |
Correct |
412 ms |
63560 KB |
Output is correct |
39 |
Correct |
447 ms |
64192 KB |
Output is correct |
40 |
Correct |
441 ms |
66900 KB |
Output is correct |
41 |
Incorrect |
17 ms |
1044 KB |
Output isn't correct |
42 |
Halted |
0 ms |
0 KB |
- |