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>
#define ll long long
#define ar array
#define db double
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rint(l, r) uniform_int_distribution<int>(l, r)(rng)
template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
const int N = 203, T = 50;
void test_case() {
int n, q; cin >> n >> q;
vector<vector<int>> a(2 * N + 1, vector<int>(2 * N + 1));
for (int i = 0; i < n; i++) {
int x, y; cin >> x >> y;
a[x+N][y+N] = 2;
}
const int dx[]{0, 1, 0, -1}, dy[]{1, 0, -1, 0};
vector<int> ans(T + 1);
ans[0] = n;
for (int t = 1; t <= T; t++) {
vector<vector<int>> b(2 * N + 1, vector<int>(2 * N + 1));
for (int i = 0; i < 2 * N + 1; i++) {
for (int j = 0; j < 2 * N + 1; j++) {
if (a[i][j] == 2) b[i][j] = 1;
else if (a[i][j] == 1) b[i][j] = 0;
else {
bool f = 0;
for (int d = 0; d < 4; d++) {
int nx = i + dx[d], ny = j + dy[d];
if (nx >= 0 && ny >= 0 && nx < 2 * N + 1 && ny < 2 * N + 1 && a[nx][ny] == 2) {
f = 1; break;
}
}
b[i][j] = f ? 2 : 0;
}
}
}
swap(a, b);
for (int i = 0; i < 2*N+1; i++) {
for (int j = 0; j < 2*N+1; j++) {
ans[t] += a[i][j] == 2;
}
}
}
while (q--) {
int t; cin >> t;
cout << ans[t] << '\n';
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
// cin >> t;
while (t--) test_case();
}
# | 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... |