#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end();
#define LCBorz ios_base::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
const int C=2002;
const int N=C<<1|1;
const int INF=1e9;
const int lim=1000;
vector<int> dx={-1,0,1,0},dy={0,1,0,-1};
int dis[N][N],ans[N];
int32_t main(){
LCBorz;
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
dis[i][j]=INF;
}
}
int n,q1;cin>>n>>q1;
queue<pair<int,int>> q;
for(int i=0;i<n;i++){
int a,b;cin>>a>>b;
dis[a+C][b+C]=0;
q.push({a+C,b+C});
}
while(q.size()){
auto [a,b]=q.front();
q.pop();
if(dis[a][b]>lim)continue;
ans[dis[a][b]]++;
for(int k=0;k<4;k++){
int c=a+dx[k];
int d=b+dy[k];
if(dis[c][d]==INF){
dis[c][d]=dis[a][b]+1;
q.push({c,d});
}
}
}
for(int i=0;i<q1;i++){
int t;cin>>t;
cout<<ans[t]<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
63144 KB |
Output is correct |
2 |
Correct |
56 ms |
63256 KB |
Output is correct |
3 |
Correct |
65 ms |
63068 KB |
Output is correct |
4 |
Correct |
59 ms |
63068 KB |
Output is correct |
5 |
Correct |
72 ms |
63248 KB |
Output is correct |
6 |
Correct |
56 ms |
63064 KB |
Output is correct |
7 |
Correct |
68 ms |
63320 KB |
Output is correct |
8 |
Correct |
66 ms |
63372 KB |
Output is correct |
9 |
Correct |
69 ms |
63244 KB |
Output is correct |
10 |
Correct |
80 ms |
63068 KB |
Output is correct |
11 |
Correct |
78 ms |
63068 KB |
Output is correct |
12 |
Correct |
72 ms |
63068 KB |
Output is correct |
13 |
Correct |
64 ms |
63064 KB |
Output is correct |
14 |
Correct |
72 ms |
63068 KB |
Output is correct |
15 |
Correct |
71 ms |
63252 KB |
Output is correct |
16 |
Correct |
55 ms |
63244 KB |
Output is correct |
17 |
Correct |
64 ms |
63068 KB |
Output is correct |
18 |
Correct |
53 ms |
63240 KB |
Output is correct |
19 |
Correct |
69 ms |
63252 KB |
Output is correct |
20 |
Correct |
54 ms |
63244 KB |
Output is correct |
21 |
Correct |
52 ms |
63064 KB |
Output is correct |
22 |
Correct |
52 ms |
63260 KB |
Output is correct |
23 |
Correct |
52 ms |
63252 KB |
Output is correct |
24 |
Correct |
62 ms |
63232 KB |
Output is correct |
25 |
Correct |
54 ms |
63068 KB |
Output is correct |
26 |
Correct |
63 ms |
63176 KB |
Output is correct |
27 |
Correct |
55 ms |
63068 KB |
Output is correct |
28 |
Correct |
56 ms |
63064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
63144 KB |
Output is correct |
2 |
Correct |
56 ms |
63256 KB |
Output is correct |
3 |
Correct |
65 ms |
63068 KB |
Output is correct |
4 |
Correct |
59 ms |
63068 KB |
Output is correct |
5 |
Correct |
72 ms |
63248 KB |
Output is correct |
6 |
Correct |
56 ms |
63064 KB |
Output is correct |
7 |
Correct |
68 ms |
63320 KB |
Output is correct |
8 |
Correct |
66 ms |
63372 KB |
Output is correct |
9 |
Correct |
69 ms |
63244 KB |
Output is correct |
10 |
Correct |
80 ms |
63068 KB |
Output is correct |
11 |
Correct |
78 ms |
63068 KB |
Output is correct |
12 |
Correct |
72 ms |
63068 KB |
Output is correct |
13 |
Correct |
64 ms |
63064 KB |
Output is correct |
14 |
Correct |
72 ms |
63068 KB |
Output is correct |
15 |
Correct |
71 ms |
63252 KB |
Output is correct |
16 |
Correct |
55 ms |
63244 KB |
Output is correct |
17 |
Correct |
64 ms |
63068 KB |
Output is correct |
18 |
Correct |
53 ms |
63240 KB |
Output is correct |
19 |
Correct |
69 ms |
63252 KB |
Output is correct |
20 |
Correct |
54 ms |
63244 KB |
Output is correct |
21 |
Correct |
52 ms |
63064 KB |
Output is correct |
22 |
Correct |
52 ms |
63260 KB |
Output is correct |
23 |
Correct |
52 ms |
63252 KB |
Output is correct |
24 |
Correct |
62 ms |
63232 KB |
Output is correct |
25 |
Correct |
54 ms |
63068 KB |
Output is correct |
26 |
Correct |
63 ms |
63176 KB |
Output is correct |
27 |
Correct |
55 ms |
63068 KB |
Output is correct |
28 |
Correct |
56 ms |
63064 KB |
Output is correct |
29 |
Correct |
56 ms |
63064 KB |
Output is correct |
30 |
Correct |
102 ms |
63312 KB |
Output is correct |
31 |
Correct |
142 ms |
63288 KB |
Output is correct |
32 |
Correct |
237 ms |
66388 KB |
Output is correct |
33 |
Correct |
93 ms |
63264 KB |
Output is correct |
34 |
Correct |
110 ms |
63276 KB |
Output is correct |
35 |
Correct |
113 ms |
63276 KB |
Output is correct |
36 |
Correct |
53 ms |
63068 KB |
Output is correct |
37 |
Correct |
52 ms |
63312 KB |
Output is correct |
38 |
Correct |
192 ms |
63324 KB |
Output is correct |
39 |
Correct |
198 ms |
64316 KB |
Output is correct |
40 |
Correct |
239 ms |
67080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
63 ms |
127884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
63 ms |
127884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
64 ms |
127828 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
64 ms |
127828 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
63144 KB |
Output is correct |
2 |
Correct |
56 ms |
63256 KB |
Output is correct |
3 |
Correct |
65 ms |
63068 KB |
Output is correct |
4 |
Correct |
59 ms |
63068 KB |
Output is correct |
5 |
Correct |
72 ms |
63248 KB |
Output is correct |
6 |
Correct |
56 ms |
63064 KB |
Output is correct |
7 |
Correct |
68 ms |
63320 KB |
Output is correct |
8 |
Correct |
66 ms |
63372 KB |
Output is correct |
9 |
Correct |
69 ms |
63244 KB |
Output is correct |
10 |
Correct |
80 ms |
63068 KB |
Output is correct |
11 |
Correct |
78 ms |
63068 KB |
Output is correct |
12 |
Correct |
72 ms |
63068 KB |
Output is correct |
13 |
Correct |
64 ms |
63064 KB |
Output is correct |
14 |
Correct |
72 ms |
63068 KB |
Output is correct |
15 |
Correct |
71 ms |
63252 KB |
Output is correct |
16 |
Correct |
55 ms |
63244 KB |
Output is correct |
17 |
Correct |
64 ms |
63068 KB |
Output is correct |
18 |
Correct |
53 ms |
63240 KB |
Output is correct |
19 |
Correct |
69 ms |
63252 KB |
Output is correct |
20 |
Correct |
54 ms |
63244 KB |
Output is correct |
21 |
Correct |
52 ms |
63064 KB |
Output is correct |
22 |
Correct |
52 ms |
63260 KB |
Output is correct |
23 |
Correct |
52 ms |
63252 KB |
Output is correct |
24 |
Correct |
62 ms |
63232 KB |
Output is correct |
25 |
Correct |
54 ms |
63068 KB |
Output is correct |
26 |
Correct |
63 ms |
63176 KB |
Output is correct |
27 |
Correct |
55 ms |
63068 KB |
Output is correct |
28 |
Correct |
56 ms |
63064 KB |
Output is correct |
29 |
Correct |
56 ms |
63064 KB |
Output is correct |
30 |
Correct |
102 ms |
63312 KB |
Output is correct |
31 |
Correct |
142 ms |
63288 KB |
Output is correct |
32 |
Correct |
237 ms |
66388 KB |
Output is correct |
33 |
Correct |
93 ms |
63264 KB |
Output is correct |
34 |
Correct |
110 ms |
63276 KB |
Output is correct |
35 |
Correct |
113 ms |
63276 KB |
Output is correct |
36 |
Correct |
53 ms |
63068 KB |
Output is correct |
37 |
Correct |
52 ms |
63312 KB |
Output is correct |
38 |
Correct |
192 ms |
63324 KB |
Output is correct |
39 |
Correct |
198 ms |
64316 KB |
Output is correct |
40 |
Correct |
239 ms |
67080 KB |
Output is correct |
41 |
Runtime error |
63 ms |
127884 KB |
Execution killed with signal 11 |
42 |
Halted |
0 ms |
0 KB |
- |