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;
typedef long long ll;
#define int long long
#define vo vector
#define fi first
#define se second
#define pr(x) cerr << #x << " " << x << endl;
#define sz(x) x.size()
typedef vo<int> vi;
typedef pair<int, int> pii;
#define rep(i, a, b) for(ll i = (a); i<(b); i++)
ll const inf = LLONG_MAX, mxn = 51;
int n, q, ans[mxn];
map<pii, int> coordinatesOdd; //coordinate to color black, grey, white
map<pii, int> coordinatesEven;
int dir[4][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}} ;
void solve(int t, map<pii, int> &coordinates, map<pii, int> &other){
other.clear();
for(auto c: coordinates){
int col = c.se;
if(col == 1){
ans[t]++;
other[c.fi] = 2;
for(auto x: dir){
ll nr = x[0] + c.fi.fi, nc = x[1] + c.fi.se;
if(!coordinates.count({nr, nc})){
other[{nr, nc}] = 1;
}
}
}
}
}
signed main(){
cin>>n>>q;
rep(i, 0, n){
int ri, ci;
cin>>ri>>ci;
coordinatesEven[{ri, ci}] = 1;
}
rep(t, 0, 50){
if(t%2==0){
solve(t, coordinatesEven, coordinatesOdd);
}
else{
solve(t, coordinatesOdd, coordinatesEven);
}
}
rep(i, 0, q){
int ti; cin>>ti;
cout << ans[ti] << "\n";
}
}
# | 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... |