답안 #1001233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1001233 2024-06-18T17:18:19 Z vjudge3 Tracks in the Snow (BOI13_tracks) C++17
95.625 / 100
1233 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;

char g[4005][4005];
bitset<4005> vis[4005];
vector<pair<short, short>> layer[10000005];
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')]);
		layer[dep-1].clear();
		if (layer[dep].empty()) {
			cout << dep-1 << '\n';
			return 0;
		}
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 238524 KB Output is correct
2 Correct 74 ms 235192 KB Output is correct
3 Correct 83 ms 235376 KB Output is correct
4 Correct 88 ms 239568 KB Output is correct
5 Correct 77 ms 236624 KB Output is correct
6 Correct 78 ms 235200 KB Output is correct
7 Correct 75 ms 235492 KB Output is correct
8 Correct 77 ms 235444 KB Output is correct
9 Correct 72 ms 235604 KB Output is correct
10 Correct 77 ms 236368 KB Output is correct
11 Correct 79 ms 237176 KB Output is correct
12 Correct 79 ms 236772 KB Output is correct
13 Correct 78 ms 236628 KB Output is correct
14 Correct 80 ms 236684 KB Output is correct
15 Correct 92 ms 238336 KB Output is correct
16 Correct 95 ms 238496 KB Output is correct
17 Correct 82 ms 237900 KB Output is correct
18 Correct 90 ms 239700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 252500 KB Output is correct
2 Correct 152 ms 244308 KB Output is correct
3 Correct 657 ms 285008 KB Output is correct
4 Correct 205 ms 246868 KB Output is correct
5 Correct 501 ms 389712 KB Output is correct
6 Correct 1065 ms 429028 KB Output is correct
7 Correct 73 ms 253428 KB Output is correct
8 Correct 89 ms 252496 KB Output is correct
9 Correct 67 ms 235608 KB Output is correct
10 Correct 67 ms 235604 KB Output is correct
11 Correct 83 ms 252884 KB Output is correct
12 Correct 75 ms 236296 KB Output is correct
13 Correct 139 ms 244416 KB Output is correct
14 Correct 108 ms 241236 KB Output is correct
15 Correct 119 ms 244308 KB Output is correct
16 Correct 105 ms 238928 KB Output is correct
17 Correct 234 ms 252588 KB Output is correct
18 Correct 236 ms 262224 KB Output is correct
19 Correct 189 ms 246952 KB Output is correct
20 Correct 203 ms 250132 KB Output is correct
21 Correct 399 ms 267724 KB Output is correct
22 Correct 504 ms 389716 KB Output is correct
23 Correct 394 ms 262772 KB Output is correct
24 Correct 415 ms 298068 KB Output is correct
25 Correct 666 ms 327408 KB Output is correct
26 Runtime error 746 ms 1048576 KB Execution killed with signal 9
27 Runtime error 1176 ms 1048576 KB Execution killed with signal 9
28 Correct 1057 ms 429024 KB Output is correct
29 Correct 1067 ms 398928 KB Output is correct
30 Correct 1099 ms 571672 KB Output is correct
31 Correct 732 ms 290664 KB Output is correct
32 Correct 1233 ms 823028 KB Output is correct