답안 #1045574

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1045574 2024-08-06T05:53:33 Z 구재현 (니혼진 지뢰계 멘헤라 갸루)(#11071) Cell Automaton (JOI23_cell) C++17
4 / 100
87 ms 40024 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(2222, vector<int>(2222, 1e9));
	vector<int> cnt(10000);
	auto ok = [&](int x, int y) { return x >= 0 && x < 2222 && y >= 0 && y < 2222; };
	queue<pi> que;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		x += 1111;
		y += 1111;
		board[x][y] = 0;
		que.push({x, y});
	}
	while (sz(que)) {
		auto [x, y] = que.front();
		que.pop();
		for (int i = 0; i < 4; i++) {
			if (ok(x + dx[i], y + dy[i]) && board[x + dx[i]][y + dy[i]] > board[x][y] + 1) {
				board[x + dx[i]][y + dy[i]] = board[x][y] + 1;
				que.push({x + dx[i], y + dy[i]});
			}
		}
	}
	for (auto &d : board) {
		for (auto &e : d) {
			cnt[e]++;
		}
	}
	while (q--) {
		int t;
		cin >> t;
		cout << cnt[t] << "\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 19800 KB Output is correct
2 Correct 73 ms 19804 KB Output is correct
3 Correct 69 ms 19804 KB Output is correct
4 Correct 81 ms 19800 KB Output is correct
5 Correct 71 ms 19904 KB Output is correct
6 Correct 65 ms 19804 KB Output is correct
7 Correct 73 ms 20060 KB Output is correct
8 Correct 73 ms 19952 KB Output is correct
9 Correct 73 ms 19804 KB Output is correct
10 Correct 72 ms 19800 KB Output is correct
11 Correct 69 ms 19800 KB Output is correct
12 Correct 78 ms 20152 KB Output is correct
13 Correct 76 ms 19800 KB Output is correct
14 Correct 73 ms 19804 KB Output is correct
15 Correct 69 ms 19800 KB Output is correct
16 Correct 73 ms 19800 KB Output is correct
17 Correct 71 ms 19900 KB Output is correct
18 Correct 75 ms 19804 KB Output is correct
19 Correct 86 ms 19800 KB Output is correct
20 Correct 73 ms 19800 KB Output is correct
21 Correct 76 ms 19804 KB Output is correct
22 Correct 79 ms 20060 KB Output is correct
23 Correct 69 ms 19800 KB Output is correct
24 Correct 87 ms 19800 KB Output is correct
25 Correct 72 ms 19800 KB Output is correct
26 Correct 74 ms 19900 KB Output is correct
27 Correct 70 ms 19900 KB Output is correct
28 Correct 67 ms 19800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 19800 KB Output is correct
2 Correct 73 ms 19804 KB Output is correct
3 Correct 69 ms 19804 KB Output is correct
4 Correct 81 ms 19800 KB Output is correct
5 Correct 71 ms 19904 KB Output is correct
6 Correct 65 ms 19804 KB Output is correct
7 Correct 73 ms 20060 KB Output is correct
8 Correct 73 ms 19952 KB Output is correct
9 Correct 73 ms 19804 KB Output is correct
10 Correct 72 ms 19800 KB Output is correct
11 Correct 69 ms 19800 KB Output is correct
12 Correct 78 ms 20152 KB Output is correct
13 Correct 76 ms 19800 KB Output is correct
14 Correct 73 ms 19804 KB Output is correct
15 Correct 69 ms 19800 KB Output is correct
16 Correct 73 ms 19800 KB Output is correct
17 Correct 71 ms 19900 KB Output is correct
18 Correct 75 ms 19804 KB Output is correct
19 Correct 86 ms 19800 KB Output is correct
20 Correct 73 ms 19800 KB Output is correct
21 Correct 76 ms 19804 KB Output is correct
22 Correct 79 ms 20060 KB Output is correct
23 Correct 69 ms 19800 KB Output is correct
24 Correct 87 ms 19800 KB Output is correct
25 Correct 72 ms 19800 KB Output is correct
26 Correct 74 ms 19900 KB Output is correct
27 Correct 70 ms 19900 KB Output is correct
28 Correct 67 ms 19800 KB Output is correct
29 Correct 72 ms 19804 KB Output is correct
30 Incorrect 66 ms 19804 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 21 ms 39772 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 21 ms 39772 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 25 ms 40024 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 25 ms 40024 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 19800 KB Output is correct
2 Correct 73 ms 19804 KB Output is correct
3 Correct 69 ms 19804 KB Output is correct
4 Correct 81 ms 19800 KB Output is correct
5 Correct 71 ms 19904 KB Output is correct
6 Correct 65 ms 19804 KB Output is correct
7 Correct 73 ms 20060 KB Output is correct
8 Correct 73 ms 19952 KB Output is correct
9 Correct 73 ms 19804 KB Output is correct
10 Correct 72 ms 19800 KB Output is correct
11 Correct 69 ms 19800 KB Output is correct
12 Correct 78 ms 20152 KB Output is correct
13 Correct 76 ms 19800 KB Output is correct
14 Correct 73 ms 19804 KB Output is correct
15 Correct 69 ms 19800 KB Output is correct
16 Correct 73 ms 19800 KB Output is correct
17 Correct 71 ms 19900 KB Output is correct
18 Correct 75 ms 19804 KB Output is correct
19 Correct 86 ms 19800 KB Output is correct
20 Correct 73 ms 19800 KB Output is correct
21 Correct 76 ms 19804 KB Output is correct
22 Correct 79 ms 20060 KB Output is correct
23 Correct 69 ms 19800 KB Output is correct
24 Correct 87 ms 19800 KB Output is correct
25 Correct 72 ms 19800 KB Output is correct
26 Correct 74 ms 19900 KB Output is correct
27 Correct 70 ms 19900 KB Output is correct
28 Correct 67 ms 19800 KB Output is correct
29 Correct 72 ms 19804 KB Output is correct
30 Incorrect 66 ms 19804 KB Output isn't correct
31 Halted 0 ms 0 KB -