#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();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
1908 KB |
Output is correct |
2 |
Correct |
64 ms |
1788 KB |
Output is correct |
3 |
Correct |
60 ms |
1784 KB |
Output is correct |
4 |
Correct |
75 ms |
1824 KB |
Output is correct |
5 |
Correct |
59 ms |
1784 KB |
Output is correct |
6 |
Correct |
57 ms |
1844 KB |
Output is correct |
7 |
Correct |
63 ms |
1788 KB |
Output is correct |
8 |
Correct |
69 ms |
1832 KB |
Output is correct |
9 |
Correct |
60 ms |
1824 KB |
Output is correct |
10 |
Correct |
58 ms |
1788 KB |
Output is correct |
11 |
Correct |
63 ms |
1812 KB |
Output is correct |
12 |
Correct |
71 ms |
1788 KB |
Output is correct |
13 |
Correct |
60 ms |
1832 KB |
Output is correct |
14 |
Correct |
57 ms |
1848 KB |
Output is correct |
15 |
Correct |
58 ms |
1788 KB |
Output is correct |
16 |
Correct |
64 ms |
1792 KB |
Output is correct |
17 |
Correct |
62 ms |
1820 KB |
Output is correct |
18 |
Correct |
57 ms |
1788 KB |
Output is correct |
19 |
Correct |
64 ms |
1828 KB |
Output is correct |
20 |
Correct |
61 ms |
1812 KB |
Output is correct |
21 |
Correct |
63 ms |
1788 KB |
Output is correct |
22 |
Correct |
65 ms |
1788 KB |
Output is correct |
23 |
Correct |
60 ms |
1788 KB |
Output is correct |
24 |
Correct |
65 ms |
1800 KB |
Output is correct |
25 |
Correct |
59 ms |
1784 KB |
Output is correct |
26 |
Correct |
64 ms |
1796 KB |
Output is correct |
27 |
Correct |
67 ms |
2040 KB |
Output is correct |
28 |
Correct |
64 ms |
1764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
1908 KB |
Output is correct |
2 |
Correct |
64 ms |
1788 KB |
Output is correct |
3 |
Correct |
60 ms |
1784 KB |
Output is correct |
4 |
Correct |
75 ms |
1824 KB |
Output is correct |
5 |
Correct |
59 ms |
1784 KB |
Output is correct |
6 |
Correct |
57 ms |
1844 KB |
Output is correct |
7 |
Correct |
63 ms |
1788 KB |
Output is correct |
8 |
Correct |
69 ms |
1832 KB |
Output is correct |
9 |
Correct |
60 ms |
1824 KB |
Output is correct |
10 |
Correct |
58 ms |
1788 KB |
Output is correct |
11 |
Correct |
63 ms |
1812 KB |
Output is correct |
12 |
Correct |
71 ms |
1788 KB |
Output is correct |
13 |
Correct |
60 ms |
1832 KB |
Output is correct |
14 |
Correct |
57 ms |
1848 KB |
Output is correct |
15 |
Correct |
58 ms |
1788 KB |
Output is correct |
16 |
Correct |
64 ms |
1792 KB |
Output is correct |
17 |
Correct |
62 ms |
1820 KB |
Output is correct |
18 |
Correct |
57 ms |
1788 KB |
Output is correct |
19 |
Correct |
64 ms |
1828 KB |
Output is correct |
20 |
Correct |
61 ms |
1812 KB |
Output is correct |
21 |
Correct |
63 ms |
1788 KB |
Output is correct |
22 |
Correct |
65 ms |
1788 KB |
Output is correct |
23 |
Correct |
60 ms |
1788 KB |
Output is correct |
24 |
Correct |
65 ms |
1800 KB |
Output is correct |
25 |
Correct |
59 ms |
1784 KB |
Output is correct |
26 |
Correct |
64 ms |
1796 KB |
Output is correct |
27 |
Correct |
67 ms |
2040 KB |
Output is correct |
28 |
Correct |
64 ms |
1764 KB |
Output is correct |
29 |
Incorrect |
67 ms |
1788 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
1880 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
1880 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
1884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
1884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
1908 KB |
Output is correct |
2 |
Correct |
64 ms |
1788 KB |
Output is correct |
3 |
Correct |
60 ms |
1784 KB |
Output is correct |
4 |
Correct |
75 ms |
1824 KB |
Output is correct |
5 |
Correct |
59 ms |
1784 KB |
Output is correct |
6 |
Correct |
57 ms |
1844 KB |
Output is correct |
7 |
Correct |
63 ms |
1788 KB |
Output is correct |
8 |
Correct |
69 ms |
1832 KB |
Output is correct |
9 |
Correct |
60 ms |
1824 KB |
Output is correct |
10 |
Correct |
58 ms |
1788 KB |
Output is correct |
11 |
Correct |
63 ms |
1812 KB |
Output is correct |
12 |
Correct |
71 ms |
1788 KB |
Output is correct |
13 |
Correct |
60 ms |
1832 KB |
Output is correct |
14 |
Correct |
57 ms |
1848 KB |
Output is correct |
15 |
Correct |
58 ms |
1788 KB |
Output is correct |
16 |
Correct |
64 ms |
1792 KB |
Output is correct |
17 |
Correct |
62 ms |
1820 KB |
Output is correct |
18 |
Correct |
57 ms |
1788 KB |
Output is correct |
19 |
Correct |
64 ms |
1828 KB |
Output is correct |
20 |
Correct |
61 ms |
1812 KB |
Output is correct |
21 |
Correct |
63 ms |
1788 KB |
Output is correct |
22 |
Correct |
65 ms |
1788 KB |
Output is correct |
23 |
Correct |
60 ms |
1788 KB |
Output is correct |
24 |
Correct |
65 ms |
1800 KB |
Output is correct |
25 |
Correct |
59 ms |
1784 KB |
Output is correct |
26 |
Correct |
64 ms |
1796 KB |
Output is correct |
27 |
Correct |
67 ms |
2040 KB |
Output is correct |
28 |
Correct |
64 ms |
1764 KB |
Output is correct |
29 |
Incorrect |
67 ms |
1788 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |