답안 #1045577

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1045577 2024-08-06T05:54:18 Z 구재현 (니혼진 지뢰계 멘헤라 갸루)(#11071) Cell Automaton (JOI23_cell) C++17
16 / 100
401 ms 157832 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(4444, vector<int>(4444, 1e9));
	vector<int> cnt(22222);
	auto ok = [&](int x, int y) { return x >= 0 && x < 4444 && y >= 0 && y < 4444; };
	queue<pi> que;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		x += 2222;
		y += 2222;
		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 276 ms 77916 KB Output is correct
2 Correct 299 ms 78032 KB Output is correct
3 Correct 339 ms 77856 KB Output is correct
4 Correct 310 ms 77908 KB Output is correct
5 Correct 279 ms 78012 KB Output is correct
6 Correct 294 ms 77912 KB Output is correct
7 Correct 305 ms 78008 KB Output is correct
8 Correct 293 ms 77916 KB Output is correct
9 Correct 304 ms 78064 KB Output is correct
10 Correct 293 ms 77912 KB Output is correct
11 Correct 297 ms 78020 KB Output is correct
12 Correct 298 ms 78036 KB Output is correct
13 Correct 312 ms 78056 KB Output is correct
14 Correct 321 ms 77908 KB Output is correct
15 Correct 297 ms 77916 KB Output is correct
16 Correct 375 ms 77912 KB Output is correct
17 Correct 286 ms 77904 KB Output is correct
18 Correct 294 ms 77992 KB Output is correct
19 Correct 352 ms 77904 KB Output is correct
20 Correct 352 ms 77908 KB Output is correct
21 Correct 322 ms 77912 KB Output is correct
22 Correct 314 ms 77912 KB Output is correct
23 Correct 271 ms 77904 KB Output is correct
24 Correct 351 ms 78020 KB Output is correct
25 Correct 294 ms 78016 KB Output is correct
26 Correct 298 ms 77912 KB Output is correct
27 Correct 305 ms 77916 KB Output is correct
28 Correct 300 ms 78164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 276 ms 77916 KB Output is correct
2 Correct 299 ms 78032 KB Output is correct
3 Correct 339 ms 77856 KB Output is correct
4 Correct 310 ms 77908 KB Output is correct
5 Correct 279 ms 78012 KB Output is correct
6 Correct 294 ms 77912 KB Output is correct
7 Correct 305 ms 78008 KB Output is correct
8 Correct 293 ms 77916 KB Output is correct
9 Correct 304 ms 78064 KB Output is correct
10 Correct 293 ms 77912 KB Output is correct
11 Correct 297 ms 78020 KB Output is correct
12 Correct 298 ms 78036 KB Output is correct
13 Correct 312 ms 78056 KB Output is correct
14 Correct 321 ms 77908 KB Output is correct
15 Correct 297 ms 77916 KB Output is correct
16 Correct 375 ms 77912 KB Output is correct
17 Correct 286 ms 77904 KB Output is correct
18 Correct 294 ms 77992 KB Output is correct
19 Correct 352 ms 77904 KB Output is correct
20 Correct 352 ms 77908 KB Output is correct
21 Correct 322 ms 77912 KB Output is correct
22 Correct 314 ms 77912 KB Output is correct
23 Correct 271 ms 77904 KB Output is correct
24 Correct 351 ms 78020 KB Output is correct
25 Correct 294 ms 78016 KB Output is correct
26 Correct 298 ms 77912 KB Output is correct
27 Correct 305 ms 77916 KB Output is correct
28 Correct 300 ms 78164 KB Output is correct
29 Correct 330 ms 78060 KB Output is correct
30 Correct 295 ms 77908 KB Output is correct
31 Correct 321 ms 77916 KB Output is correct
32 Correct 366 ms 81348 KB Output is correct
33 Correct 306 ms 77912 KB Output is correct
34 Correct 301 ms 78292 KB Output is correct
35 Correct 321 ms 77912 KB Output is correct
36 Correct 349 ms 78020 KB Output is correct
37 Correct 289 ms 77916 KB Output is correct
38 Correct 334 ms 78168 KB Output is correct
39 Correct 377 ms 79088 KB Output is correct
40 Correct 401 ms 81636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 78 ms 157832 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 78 ms 157832 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 96 ms 157772 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 96 ms 157772 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 276 ms 77916 KB Output is correct
2 Correct 299 ms 78032 KB Output is correct
3 Correct 339 ms 77856 KB Output is correct
4 Correct 310 ms 77908 KB Output is correct
5 Correct 279 ms 78012 KB Output is correct
6 Correct 294 ms 77912 KB Output is correct
7 Correct 305 ms 78008 KB Output is correct
8 Correct 293 ms 77916 KB Output is correct
9 Correct 304 ms 78064 KB Output is correct
10 Correct 293 ms 77912 KB Output is correct
11 Correct 297 ms 78020 KB Output is correct
12 Correct 298 ms 78036 KB Output is correct
13 Correct 312 ms 78056 KB Output is correct
14 Correct 321 ms 77908 KB Output is correct
15 Correct 297 ms 77916 KB Output is correct
16 Correct 375 ms 77912 KB Output is correct
17 Correct 286 ms 77904 KB Output is correct
18 Correct 294 ms 77992 KB Output is correct
19 Correct 352 ms 77904 KB Output is correct
20 Correct 352 ms 77908 KB Output is correct
21 Correct 322 ms 77912 KB Output is correct
22 Correct 314 ms 77912 KB Output is correct
23 Correct 271 ms 77904 KB Output is correct
24 Correct 351 ms 78020 KB Output is correct
25 Correct 294 ms 78016 KB Output is correct
26 Correct 298 ms 77912 KB Output is correct
27 Correct 305 ms 77916 KB Output is correct
28 Correct 300 ms 78164 KB Output is correct
29 Correct 330 ms 78060 KB Output is correct
30 Correct 295 ms 77908 KB Output is correct
31 Correct 321 ms 77916 KB Output is correct
32 Correct 366 ms 81348 KB Output is correct
33 Correct 306 ms 77912 KB Output is correct
34 Correct 301 ms 78292 KB Output is correct
35 Correct 321 ms 77912 KB Output is correct
36 Correct 349 ms 78020 KB Output is correct
37 Correct 289 ms 77916 KB Output is correct
38 Correct 334 ms 78168 KB Output is correct
39 Correct 377 ms 79088 KB Output is correct
40 Correct 401 ms 81636 KB Output is correct
41 Runtime error 78 ms 157832 KB Execution killed with signal 11
42 Halted 0 ms 0 KB -