This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |