#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define int long long
#define lowbit(x) x&-x
const int maxn = 4000 + 5;
const int INF = 1e18;
int dist[maxn][maxn];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int n, q;
void sol1(vector<pll> e){
queue<pll> qq;
for(int i = 0; i < maxn; i++) for(int j = 0; j < maxn; j++) dist[i][j] = INF;
for(auto [x, y] : e){
x += maxn / 2, y += maxn / 2;
dist[x][y] = 0;
qq.push({x, y});
}
vector<int> ans(maxn * 2);
ans[0] = e.size();
auto inbound = [&](int x, int y) -> bool {
return x >= 0 && y >= 0 && x < maxn && y < maxn;
};
while(!qq.empty()){
auto [x, y] = qq.front(); qq.pop();
for(int d = 0; d < 4; d++){
int xx = x + dx[d], yy = y + dy[d];
if(!inbound(xx, yy) || dist[xx][yy] < INF) continue;
dist[xx][yy] = dist[x][y] + 1;
ans[dist[xx][yy]] += 1;
qq.push({xx, yy});
}
}
for(int i = 0; i < q; i++){
int t;
cin>>t;
cout<<ans[t]<<"\n";
}
return;
}
signed main(void){
// fastio;
cin>>n>>q;
int mx = 0;
vector<pll> e;
for(int i = 0; i < n; i++){
int x, y;
cin>>x>>y;
mx = max(mx, max(abs(x), abs(y)));
e.pb({x, y});
}
if(mx <= 1000){
sol1(e);
return 0;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
451 ms |
126172 KB |
Output is correct |
2 |
Correct |
439 ms |
126292 KB |
Output is correct |
3 |
Correct |
418 ms |
126312 KB |
Output is correct |
4 |
Correct |
424 ms |
126100 KB |
Output is correct |
5 |
Correct |
460 ms |
126104 KB |
Output is correct |
6 |
Correct |
450 ms |
126172 KB |
Output is correct |
7 |
Correct |
437 ms |
126100 KB |
Output is correct |
8 |
Correct |
461 ms |
126532 KB |
Output is correct |
9 |
Correct |
450 ms |
126036 KB |
Output is correct |
10 |
Correct |
443 ms |
126172 KB |
Output is correct |
11 |
Correct |
450 ms |
126172 KB |
Output is correct |
12 |
Correct |
436 ms |
126020 KB |
Output is correct |
13 |
Correct |
436 ms |
126200 KB |
Output is correct |
14 |
Correct |
432 ms |
126036 KB |
Output is correct |
15 |
Correct |
419 ms |
126036 KB |
Output is correct |
16 |
Correct |
431 ms |
126292 KB |
Output is correct |
17 |
Correct |
463 ms |
126104 KB |
Output is correct |
18 |
Correct |
442 ms |
126304 KB |
Output is correct |
19 |
Correct |
447 ms |
125940 KB |
Output is correct |
20 |
Correct |
430 ms |
126072 KB |
Output is correct |
21 |
Correct |
422 ms |
126296 KB |
Output is correct |
22 |
Correct |
434 ms |
126100 KB |
Output is correct |
23 |
Correct |
446 ms |
126184 KB |
Output is correct |
24 |
Correct |
451 ms |
126160 KB |
Output is correct |
25 |
Correct |
444 ms |
126152 KB |
Output is correct |
26 |
Correct |
446 ms |
126168 KB |
Output is correct |
27 |
Correct |
430 ms |
126168 KB |
Output is correct |
28 |
Correct |
450 ms |
126296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
451 ms |
126172 KB |
Output is correct |
2 |
Correct |
439 ms |
126292 KB |
Output is correct |
3 |
Correct |
418 ms |
126312 KB |
Output is correct |
4 |
Correct |
424 ms |
126100 KB |
Output is correct |
5 |
Correct |
460 ms |
126104 KB |
Output is correct |
6 |
Correct |
450 ms |
126172 KB |
Output is correct |
7 |
Correct |
437 ms |
126100 KB |
Output is correct |
8 |
Correct |
461 ms |
126532 KB |
Output is correct |
9 |
Correct |
450 ms |
126036 KB |
Output is correct |
10 |
Correct |
443 ms |
126172 KB |
Output is correct |
11 |
Correct |
450 ms |
126172 KB |
Output is correct |
12 |
Correct |
436 ms |
126020 KB |
Output is correct |
13 |
Correct |
436 ms |
126200 KB |
Output is correct |
14 |
Correct |
432 ms |
126036 KB |
Output is correct |
15 |
Correct |
419 ms |
126036 KB |
Output is correct |
16 |
Correct |
431 ms |
126292 KB |
Output is correct |
17 |
Correct |
463 ms |
126104 KB |
Output is correct |
18 |
Correct |
442 ms |
126304 KB |
Output is correct |
19 |
Correct |
447 ms |
125940 KB |
Output is correct |
20 |
Correct |
430 ms |
126072 KB |
Output is correct |
21 |
Correct |
422 ms |
126296 KB |
Output is correct |
22 |
Correct |
434 ms |
126100 KB |
Output is correct |
23 |
Correct |
446 ms |
126184 KB |
Output is correct |
24 |
Correct |
451 ms |
126160 KB |
Output is correct |
25 |
Correct |
444 ms |
126152 KB |
Output is correct |
26 |
Correct |
446 ms |
126168 KB |
Output is correct |
27 |
Correct |
430 ms |
126168 KB |
Output is correct |
28 |
Correct |
450 ms |
126296 KB |
Output is correct |
29 |
Correct |
435 ms |
126064 KB |
Output is correct |
30 |
Correct |
456 ms |
126180 KB |
Output is correct |
31 |
Correct |
478 ms |
126280 KB |
Output is correct |
32 |
Correct |
483 ms |
135048 KB |
Output is correct |
33 |
Correct |
443 ms |
126164 KB |
Output is correct |
34 |
Correct |
448 ms |
126036 KB |
Output is correct |
35 |
Correct |
440 ms |
126216 KB |
Output is correct |
36 |
Correct |
449 ms |
126556 KB |
Output is correct |
37 |
Correct |
453 ms |
125968 KB |
Output is correct |
38 |
Correct |
416 ms |
126716 KB |
Output is correct |
39 |
Correct |
453 ms |
128460 KB |
Output is correct |
40 |
Correct |
500 ms |
135872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
70 ms |
2504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
70 ms |
2504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
451 ms |
126172 KB |
Output is correct |
2 |
Correct |
439 ms |
126292 KB |
Output is correct |
3 |
Correct |
418 ms |
126312 KB |
Output is correct |
4 |
Correct |
424 ms |
126100 KB |
Output is correct |
5 |
Correct |
460 ms |
126104 KB |
Output is correct |
6 |
Correct |
450 ms |
126172 KB |
Output is correct |
7 |
Correct |
437 ms |
126100 KB |
Output is correct |
8 |
Correct |
461 ms |
126532 KB |
Output is correct |
9 |
Correct |
450 ms |
126036 KB |
Output is correct |
10 |
Correct |
443 ms |
126172 KB |
Output is correct |
11 |
Correct |
450 ms |
126172 KB |
Output is correct |
12 |
Correct |
436 ms |
126020 KB |
Output is correct |
13 |
Correct |
436 ms |
126200 KB |
Output is correct |
14 |
Correct |
432 ms |
126036 KB |
Output is correct |
15 |
Correct |
419 ms |
126036 KB |
Output is correct |
16 |
Correct |
431 ms |
126292 KB |
Output is correct |
17 |
Correct |
463 ms |
126104 KB |
Output is correct |
18 |
Correct |
442 ms |
126304 KB |
Output is correct |
19 |
Correct |
447 ms |
125940 KB |
Output is correct |
20 |
Correct |
430 ms |
126072 KB |
Output is correct |
21 |
Correct |
422 ms |
126296 KB |
Output is correct |
22 |
Correct |
434 ms |
126100 KB |
Output is correct |
23 |
Correct |
446 ms |
126184 KB |
Output is correct |
24 |
Correct |
451 ms |
126160 KB |
Output is correct |
25 |
Correct |
444 ms |
126152 KB |
Output is correct |
26 |
Correct |
446 ms |
126168 KB |
Output is correct |
27 |
Correct |
430 ms |
126168 KB |
Output is correct |
28 |
Correct |
450 ms |
126296 KB |
Output is correct |
29 |
Correct |
435 ms |
126064 KB |
Output is correct |
30 |
Correct |
456 ms |
126180 KB |
Output is correct |
31 |
Correct |
478 ms |
126280 KB |
Output is correct |
32 |
Correct |
483 ms |
135048 KB |
Output is correct |
33 |
Correct |
443 ms |
126164 KB |
Output is correct |
34 |
Correct |
448 ms |
126036 KB |
Output is correct |
35 |
Correct |
440 ms |
126216 KB |
Output is correct |
36 |
Correct |
449 ms |
126556 KB |
Output is correct |
37 |
Correct |
453 ms |
125968 KB |
Output is correct |
38 |
Correct |
416 ms |
126716 KB |
Output is correct |
39 |
Correct |
453 ms |
128460 KB |
Output is correct |
40 |
Correct |
500 ms |
135872 KB |
Output is correct |
41 |
Incorrect |
70 ms |
2504 KB |
Output isn't correct |
42 |
Halted |
0 ms |
0 KB |
- |