Submission #1001224

# Submission time Handle Problem Language Result Execution time Memory
1001224 2024-06-18T17:12:01 Z vjudge3 Tracks in the Snow (BOI13_tracks) C++17
67.1875 / 100
1359 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;

char g[4005][4005];
bool vis[4005][4005];
vector<pair<int, int>> layer[4005];
int h, w, dep = 1;
const int dr[4] = {0, 1, 0, -1}, dc[4] = {1, 0, -1, 0};

void dfs (int r, int c, char ch) {
	if (!vis[r][c]) layer[dep].push_back({r, c});
	vis[r][c] = true;
	for (int k = 0; k < 4; k++) {
		int rv = r + dr[k], cv = c + dc[k];
		if (rv >= 1 && rv <= h && cv >= 1 && cv <= w && !vis[rv][cv] && g[rv][cv] == ch) dfs(rv, cv, ch);
	}
}

int main () {
	cin >> h >> w;
	for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) cin >> g[i][j];
	dfs(1, 1, g[1][1]);
	while (true) {
		dep++;
		for (auto& [r, c] : layer[dep-1]) dfs(r, c, "RF"[(dep & 1) ^ (g[1][1] == 'R')]);
		if (layer[dep].empty()) {
			cout << dep-1 << '\n';
			return 0;
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 18 ms 8792 KB Output is correct
2 Correct 0 ms 2648 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 17 ms 9472 KB Output is correct
5 Correct 4 ms 5980 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2908 KB Output is correct
9 Correct 1 ms 2908 KB Output is correct
10 Correct 4 ms 5980 KB Output is correct
11 Correct 4 ms 4568 KB Output is correct
12 Correct 7 ms 6508 KB Output is correct
13 Correct 5 ms 5980 KB Output is correct
14 Correct 4 ms 5980 KB Output is correct
15 Correct 17 ms 8584 KB Output is correct
16 Correct 19 ms 8788 KB Output is correct
17 Correct 14 ms 7772 KB Output is correct
18 Correct 12 ms 9304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 64348 KB Execution killed with signal 6
2 Correct 77 ms 19536 KB Output is correct
3 Runtime error 474 ms 82256 KB Execution killed with signal 6
4 Correct 142 ms 27728 KB Output is correct
5 Runtime error 265 ms 63828 KB Execution killed with signal 6
6 Correct 1113 ms 266008 KB Output is correct
7 Runtime error 30 ms 65372 KB Execution killed with signal 11
8 Runtime error 32 ms 64284 KB Execution killed with signal 6
9 Correct 4 ms 3160 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 10 ms 31828 KB Output is correct
12 Runtime error 5 ms 6444 KB Execution killed with signal 6
13 Correct 75 ms 19540 KB Output is correct
14 Correct 58 ms 14932 KB Output is correct
15 Runtime error 45 ms 22868 KB Execution killed with signal 6
16 Correct 35 ms 10576 KB Output is correct
17 Correct 236 ms 37892 KB Output is correct
18 Runtime error 125 ms 42320 KB Execution killed with signal 6
19 Correct 150 ms 27784 KB Output is correct
20 Runtime error 109 ms 36220 KB Execution killed with signal 6
21 Runtime error 279 ms 65360 KB Execution killed with signal 6
22 Runtime error 274 ms 63796 KB Execution killed with signal 6
23 Runtime error 422 ms 112888 KB Execution killed with signal 6
24 Runtime error 272 ms 65028 KB Execution killed with signal 6
25 Runtime error 482 ms 81656 KB Execution killed with signal 6
26 Runtime error 954 ms 1048576 KB Execution killed with signal 9
27 Correct 1359 ms 788228 KB Output is correct
28 Correct 1159 ms 265892 KB Output is correct
29 Correct 1212 ms 238284 KB Output is correct
30 Correct 1171 ms 407548 KB Output is correct
31 Correct 825 ms 118676 KB Output is correct
32 Correct 1196 ms 599364 KB Output is correct