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<int> ans(1000+1, -1);
int r;
for(int steps= 0; steps<1000+1; steps++){
r=0;
for(auto e: cur){
if(e.second ==2){
r++;
}
}
ans[steps] = r;
cur = next(cur);
}
int max_s= 0;
for(int i = 0; i<q; i++){
int steps= 0;
cin>>steps;
cout<<ans[steps]<<endl;
}
}
Compilation message (stderr)
cell.cpp: In function 'int main()':
cell.cpp:78:9: warning: unused variable 'max_s' [-Wunused-variable]
78 | int max_s= 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... |