#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T1, typename T2>
using indexed_map = tree<T1, T2, less<T1>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_set = indexed_map<T, null_type>;
#define loop(x, i) for (int i = 0; i < (x); i++)
#define loop1(x, i) for (int i = 1; i <= (x); i++)
#define rev(x, i) for (int i = (int)(x) - 1; i >= 0; i--)
#define itloop(x) for (auto it = begin(x); x != end(x); it++)
#define itrev(x) for (auto it = rbegin(x); x != rend(x); it++)
// #define int long long
// #define INF ((int64_t)(4e18 + 1))
#define INF32 ((int32_t)(2e9 + 1))
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define removeIn(x, l) l.erase(find(ALL(l), x))
#define pb push_back
#define sz(x) (int)(x).size()
#define F first
#define S second
#define var const auto &
#define foreach(l) for (var e : l)
typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef vector<int> vi;
typedef vector<i32> vi32;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vi32> vvi32;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<iiii> viiii;
typedef vector<vii> vvii;
typedef vector<viii> vviii;
typedef set<int> si;
typedef set<ii> sii;
typedef map<int, int> mii;
typedef set<iii> siii;
typedef vector<si> vsi;
typedef vector<sii> vsii;
typedef vector<vsi> vvsi;
typedef vector<string> vstr;
typedef vector<vector<string>> vvstr;
typedef vector<bool> vb;
typedef vector<vb> vvb;
template <typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p)
{
in >> p.first >> p.second;
return in;
}
template <typename... Ts>
istream &operator>>(istream &in, tuple<Ts...> &t)
{
apply([&in](Ts &...elems)
{ ((in >> elems), ...); }, t);
return in;
}
template <typename... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t)
{
apply([&os](const Args &...args)
{ size_t n = 0; ((os << ' ' << args), ...); }, t);
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
os << p.F << ' ' << p.S;
return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
for (auto &element : vec)
is >> element;
return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
for (auto &element : vec)
os << element << ' ';
return os;
}
template <typename... T>
void DBG(T &&...args) { ((cerr << args << ' '), ...) << endl; }
template <typename... T>
void print(T &&...args) { ((cout << args << ' '), ...) << endl; }
template <typename... T>
void read(T &&...args) { ((cin >> args), ...); }
constexpr int ADD = 2005;
constexpr int SIZE = 4010;
void solve()
{
auto adj = [&](int x, int y) -> vii
{
return {{x + 1, y}, {x - 1, y}, {x, y + 1}, {x, y - 1}};
};
int n, q;
read(n, q);
vii pts(n);
read(pts);
vi T(q);
read(T);
vii pts2;
array<bitset<SIZE>, SIZE> black1;
array<bitset<SIZE>, SIZE> black2;
int cnt = n;
int j = 0;
for (auto &[x, y] : pts)
{
x += ADD;
y += ADD;
black1[x][y] = 1;
}
if (T[0] == 0)
{
print(n);
j++;
}
for (int t = 0; t < T.back(); t++)
{
cnt = 0;
pts2.reserve(sz(pts) + 4);
for (var[x, y] : pts)
{
for (var[x2, y2] : adj(x, y))
{
if (!black1[x2][y2] && !black2[x2][y2])
{
pts2.pb({x2, y2});
black2[x2][y2] = 1;
cnt++;
}
}
}
swap(black1, black2);
swap(pts, pts2);
pts2.clear();
// loop(SIZE, i) black2[i].reset();
// 1000 * 4000 * 4000 / 32 / (1e8/s) = 5s < 8s
if (t + 1 == T[j])
{
print(cnt);
j++;
}
}
}
signed main()
{
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
string name = "";
if (sz(name))
{
if (!freopen((name + ".in").c_str(), "r", stdin) || !freopen((name + ".out").c_str(), "w", stdout))
return 1;
}
int t = 1;
// read(t);
while (t--)
solve();
}
# | 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... |