답안 #1109364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1109364 2024-11-06T15:03:25 Z classic Tracks in the Snow (BOI13_tracks) C++17
9.375 / 100
522 ms 130104 KB
#include <bits/stdc++.h>

const std::vector<int> directionX{-1, 1, 0, 0};
const std::vector<int> directionY{0, 0, -1, 1};

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int numRow, numColumn;
	std::cin >> numRow >> numColumn;
	std::vector<std::string> snow(numRow);
	for (int row = 0; row < numRow; row++) {
		std::cin >> snow[row];
	}
	std::deque<std::pair<int, int>> deque;
	std::vector<std::vector<int>> depth(numRow, std::vector<int>(numColumn));
	deque.emplace_back(0, 0);
	depth[0][0] = 1;
	int result = 1;
	while (!deque.empty()) {
		auto [currentRow, currentColumn] = deque.front();
		deque.pop_front();
		result = std::max(result, depth[currentRow][currentColumn]);
		for (int direction = 0; direction < 4; direction++) {
			int nextRow = currentRow + directionX[direction];
			int nextColumn = currentColumn + directionY[direction];
			if (nextRow >= 0 && nextRow < numRow && nextColumn >= 0 && nextColumn < numColumn && depth[nextRow][nextColumn] == 0) {
				if (snow[currentRow][currentColumn] == snow[nextRow][nextColumn]) {
					depth[nextRow][nextColumn] = depth[currentRow][currentColumn];
					deque.emplace_front(nextRow, nextColumn);
				} else {
					depth[nextRow][nextColumn] = depth[currentRow][nextColumn] + 1;
					deque.emplace_back(nextRow, nextColumn);
				}
			}
		}
	}
	std::cout << result;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1616 KB Output isn't correct
2 Incorrect 1 ms 512 KB Output isn't correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Correct 5 ms 1360 KB Output is correct
5 Incorrect 3 ms 1016 KB Output isn't correct
6 Incorrect 1 ms 336 KB Output isn't correct
7 Incorrect 1 ms 336 KB Output isn't correct
8 Incorrect 1 ms 336 KB Output isn't correct
9 Incorrect 1 ms 336 KB Output isn't correct
10 Incorrect 2 ms 848 KB Output isn't correct
11 Correct 2 ms 592 KB Output is correct
12 Incorrect 3 ms 848 KB Output isn't correct
13 Incorrect 3 ms 1016 KB Output isn't correct
14 Incorrect 3 ms 956 KB Output isn't correct
15 Incorrect 8 ms 2068 KB Output isn't correct
16 Incorrect 9 ms 1748 KB Output isn't correct
17 Incorrect 7 ms 1788 KB Output isn't correct
18 Correct 4 ms 1360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 848 KB Output isn't correct
2 Incorrect 33 ms 11776 KB Output isn't correct
3 Incorrect 327 ms 130104 KB Output isn't correct
4 Incorrect 89 ms 19792 KB Output isn't correct
5 Incorrect 195 ms 86604 KB Output isn't correct
6 Incorrect 434 ms 94160 KB Output isn't correct
7 Incorrect 2 ms 848 KB Output isn't correct
8 Incorrect 3 ms 848 KB Output isn't correct
9 Incorrect 2 ms 848 KB Output isn't correct
10 Incorrect 1 ms 592 KB Output isn't correct
11 Incorrect 2 ms 1104 KB Output isn't correct
12 Incorrect 2 ms 592 KB Output isn't correct
13 Incorrect 33 ms 11856 KB Output isn't correct
14 Incorrect 19 ms 6992 KB Output isn't correct
15 Incorrect 22 ms 8272 KB Output isn't correct
16 Incorrect 15 ms 4944 KB Output isn't correct
17 Incorrect 78 ms 30672 KB Output isn't correct
18 Incorrect 106 ms 29484 KB Output isn't correct
19 Incorrect 89 ms 21584 KB Output isn't correct
20 Incorrect 72 ms 28744 KB Output isn't correct
21 Incorrect 181 ms 77980 KB Output isn't correct
22 Incorrect 166 ms 87224 KB Output isn't correct
23 Incorrect 177 ms 60616 KB Output isn't correct
24 Incorrect 166 ms 74348 KB Output isn't correct
25 Incorrect 522 ms 118708 KB Output isn't correct
26 Correct 259 ms 118460 KB Output is correct
27 Incorrect 320 ms 104812 KB Output isn't correct
28 Incorrect 455 ms 101644 KB Output isn't correct
29 Incorrect 451 ms 96532 KB Output isn't correct
30 Correct 393 ms 93848 KB Output is correct
31 Incorrect 358 ms 57416 KB Output isn't correct
32 Incorrect 317 ms 96760 KB Output isn't correct