#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p)
{
return os << "(" << p.first << "," << p.second << ")";
}
template<typename T>
void print(T v)
{
for(auto x : v)
cout << x << " ";
cout << "\n";
}
int main()
{
int N, Q;
cin >> N >> Q;
set<pair<int, int>> black, gray;
for(int i = 0; i < N; i++)
{
int x, y;
cin >> x >> y;
black.insert({x, y});
}
vector<int> ans(1005, 0);
for(int i = 0; i <= 1000; i++)
{
// cout << "at " << i << "\n";
// print(black);
// print(gray);
ans[i] = black.size();
set<pair<int, int>> tmp1, tmp2;
for(auto [x, y] : black)
{
if(!gray.count({x - 1, y}) && !black.count({x - 1, y})) tmp1.insert({x - 1, y});
if(!gray.count({x + 1, y}) && !black.count({x + 1, y})) tmp1.insert({x + 1, y});
if(!gray.count({x, y - 1}) && !black.count({x, y - 1})) tmp1.insert({x, y - 1});
if(!gray.count({x, y + 1}) && !black.count({x, y + 1})) tmp1.insert({x, y + 1});
tmp2.insert({x, y});
}
black = tmp1;
gray = tmp2;
}
for(int i = 0; i < Q; i++)
{
int x;
cin >> x;
cout << ans[x] << "\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... |