Submission #1045555

# Submission time Handle Problem Language Result Execution time Memory
1045555 2024-08-06T05:38:39 Z 구재현 (니혼진 지뢰계 멘헤라 갸루)(#11071) Cell Automaton (JOI23_cell) C++17
4 / 100
31 ms 1024 KB
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = array<int, 2>;
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define cr(v, n) (v).clear(), (v).resize(n);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, q;
	cin >> n >> q;
	vector<vector<int>> board(222, vector<int>(222));
	auto ok = [&](int x, int y) { return x >= 0 && x < 222 && y >= 0 && y < 222 && board[x][y] == 2; };
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		x += 111;
		y += 111;
		board[x][y] = 2;
	}
	vector<int> cnt(55);
	for (int t = 1; t <= 51; t++) {
		for (auto &z : board)
			for (auto &q : z)
				if (q == 2)
					cnt[t - 1]++;
		vector<vector<int>> nxt(222, vector<int>(222));
		for (int x = 0; x < 222; x++) {
			for (int y = 0; y < 222; y++) {
				if (board[x][y] == 2)
					nxt[x][y] = 1;
				else if (board[x][y] == 1)
					nxt[x][y] = 0;
				else {
					nxt[x][y] = 0;
					for (int d = 0; d < 4; d++) {
						if (ok(x + dx[d], y + dy[d]))
							nxt[x][y] = 2;
					}
				}
			}
		}
		board = nxt;
	}
	while (q--) {
		int t;
		cin >> t;
		cout << cnt[t] << "\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 856 KB Output is correct
2 Correct 15 ms 852 KB Output is correct
3 Correct 31 ms 852 KB Output is correct
4 Correct 15 ms 848 KB Output is correct
5 Correct 15 ms 852 KB Output is correct
6 Correct 15 ms 844 KB Output is correct
7 Correct 20 ms 1004 KB Output is correct
8 Correct 15 ms 924 KB Output is correct
9 Correct 15 ms 852 KB Output is correct
10 Correct 15 ms 856 KB Output is correct
11 Correct 15 ms 848 KB Output is correct
12 Correct 15 ms 868 KB Output is correct
13 Correct 31 ms 856 KB Output is correct
14 Correct 15 ms 1024 KB Output is correct
15 Correct 15 ms 856 KB Output is correct
16 Correct 14 ms 852 KB Output is correct
17 Correct 21 ms 848 KB Output is correct
18 Correct 15 ms 848 KB Output is correct
19 Correct 15 ms 852 KB Output is correct
20 Correct 30 ms 856 KB Output is correct
21 Correct 16 ms 852 KB Output is correct
22 Correct 15 ms 852 KB Output is correct
23 Correct 15 ms 848 KB Output is correct
24 Correct 15 ms 852 KB Output is correct
25 Correct 15 ms 852 KB Output is correct
26 Correct 15 ms 856 KB Output is correct
27 Correct 15 ms 852 KB Output is correct
28 Correct 15 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 856 KB Output is correct
2 Correct 15 ms 852 KB Output is correct
3 Correct 31 ms 852 KB Output is correct
4 Correct 15 ms 848 KB Output is correct
5 Correct 15 ms 852 KB Output is correct
6 Correct 15 ms 844 KB Output is correct
7 Correct 20 ms 1004 KB Output is correct
8 Correct 15 ms 924 KB Output is correct
9 Correct 15 ms 852 KB Output is correct
10 Correct 15 ms 856 KB Output is correct
11 Correct 15 ms 848 KB Output is correct
12 Correct 15 ms 868 KB Output is correct
13 Correct 31 ms 856 KB Output is correct
14 Correct 15 ms 1024 KB Output is correct
15 Correct 15 ms 856 KB Output is correct
16 Correct 14 ms 852 KB Output is correct
17 Correct 21 ms 848 KB Output is correct
18 Correct 15 ms 848 KB Output is correct
19 Correct 15 ms 852 KB Output is correct
20 Correct 30 ms 856 KB Output is correct
21 Correct 16 ms 852 KB Output is correct
22 Correct 15 ms 852 KB Output is correct
23 Correct 15 ms 848 KB Output is correct
24 Correct 15 ms 852 KB Output is correct
25 Correct 15 ms 852 KB Output is correct
26 Correct 15 ms 856 KB Output is correct
27 Correct 15 ms 852 KB Output is correct
28 Correct 15 ms 856 KB Output is correct
29 Incorrect 15 ms 856 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 856 KB Output is correct
2 Correct 15 ms 852 KB Output is correct
3 Correct 31 ms 852 KB Output is correct
4 Correct 15 ms 848 KB Output is correct
5 Correct 15 ms 852 KB Output is correct
6 Correct 15 ms 844 KB Output is correct
7 Correct 20 ms 1004 KB Output is correct
8 Correct 15 ms 924 KB Output is correct
9 Correct 15 ms 852 KB Output is correct
10 Correct 15 ms 856 KB Output is correct
11 Correct 15 ms 848 KB Output is correct
12 Correct 15 ms 868 KB Output is correct
13 Correct 31 ms 856 KB Output is correct
14 Correct 15 ms 1024 KB Output is correct
15 Correct 15 ms 856 KB Output is correct
16 Correct 14 ms 852 KB Output is correct
17 Correct 21 ms 848 KB Output is correct
18 Correct 15 ms 848 KB Output is correct
19 Correct 15 ms 852 KB Output is correct
20 Correct 30 ms 856 KB Output is correct
21 Correct 16 ms 852 KB Output is correct
22 Correct 15 ms 852 KB Output is correct
23 Correct 15 ms 848 KB Output is correct
24 Correct 15 ms 852 KB Output is correct
25 Correct 15 ms 852 KB Output is correct
26 Correct 15 ms 856 KB Output is correct
27 Correct 15 ms 852 KB Output is correct
28 Correct 15 ms 856 KB Output is correct
29 Incorrect 15 ms 856 KB Output isn't correct
30 Halted 0 ms 0 KB -