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;
#define int long long
#define pii pair<int, int>
pii delta[4] ={{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
vector<pii> find_adj(pii pos){
vector<pii> res;
for(int i = 0; i<4; i++){
res.push_back({pos.first+delta[i].first, pos.second + delta[i].second});
}
return res;
}
map<pii, int> next(map<pii, int> cur){
map<pii, int> res;
for(auto e: cur){
if(e.second >0){
res[e.first] =e.second-1;
}
}
for(auto e: cur){
if(e.second ==2){
for(auto ee: find_adj(e.first)){
if(res.find(ee)==res.end()){
res[ee] = 2;
}
}
}
}
return res;
}
const int sz= 10;
void display(map<pii, int>&m){
for(int i = -sz; i<=sz; i++){
for(int j = -sz; j<=sz; j++){
if(m.find({i, j})!=m.end()){
cout<<m[{i, j}];
}
else{
cout<<"0";
}
}
cout<<endl;
}
cout<<endl;
}
signed main(){
int n, q;
cin>>n>>q;
map<pii, int> cur;
for(int i = 0; i<n; i++){
int x, y;
cin>>x>>y;
cur[{x, y}] = 2;
}
vector<map<pii, int>> vc;
vc.push_back(cur);
int max_s= 0;
for(int i = 0; i<q; i++){
int steps= 0;
cin>>steps;
auto qcur = cur;
for(int j = max_s+1; j<=steps; j++){
vc.push_back(next(vc.back()));
}
max_s= max(max_s, steps);
int r= 0;
for(auto e: vc[steps]){
if(e.second ==2){
r++;
}
}
cout<<r<<endl;
}
}
# | 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... |