#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt,sse4")
#define pii pair<int,int>
#define fs first
#define sc second
const int mxn = 6010;
const int sh = mxn>>1;
int N,Q;
int req[mxn];
pii dir[] = {{-1,0},{1,0},{0,1},{0,-1}};
vector<pii> v;
vector<pii> vv;
int arr[mxn][mxn];
int ans = 0;
void move(){
ans = 0;
vv.clear();
for(auto &i:v){
for(auto &d:dir){
if(!arr[i.fs+d.fs][i.sc+d.sc]){
arr[i.fs+d.fs][i.sc+d.sc] = true;
vv.push_back(pii(i.fs+d.fs,i.sc+d.sc));
ans++;
}
}
}
vv.swap(v);
return;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>Q;
for(int i = 0;i<N;i++){
int r,c;
cin>>r>>c;
arr[r+sh][c+sh] = 1;
v.push_back(pii(r+sh,c+sh));
}
int t = 0;
while(Q--){
int k;
cin>>k;
while(t<k){
t++;
move();
}
cout<<ans<<'\n';
/*
for(auto &i:arr){
for(auto &j:i)cout<<j;cout<<endl;
}cout<<endl;
*/
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
536 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
536 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
35 ms |
50720 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
35 ms |
50720 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |