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>
#pragma GCC optimize("O3","unroll-loops")
#pragma GCC target("avx2","popcnt","sse4","abm")
using namespace std;
#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MXN = 500005, MXC = 4105;
int n, Q;
int a[MXC][MXC];
queue<pii> q;
int ans[MXC];
void miku() {
int x, y;
cin >> n >> Q;
FOR(i, 0, MXC) FOR(j, 0, MXC) a[i][j] = MXC - 1;
FOR(i, 0, n) {
cin >> x >> y;
x += 2005;
y += 2005;
a[x][y] = 0;
q.push(mp(x, y));
}
auto PUSH = [&](int x, int y, int k) -> void {
if (a[x][y] < MXC - 1) return;
a[x][y] = k + 1;
q.push(mp(x, y));
};
while (q.size()) {
auto [x, y] = q.front();
q.pop();
if (a[x][y] == 1005) break;
PUSH(x + 1, y, a[x][y]);
PUSH(x, y + 1, a[x][y]);
PUSH(x - 1, y, a[x][y]);
PUSH(x, y - 1, a[x][y]);
}
FOR(i, 0, MXC) FOR(j, 0, MXC) ans[a[i][j]]++;
while (Q--) {
cin >> n;
cout << ans[n] << '\n';
}
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin.exceptions(cin.failbit);
miku();
return 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... |