Submission #1109367

# Submission time Handle Problem Language Result Execution time Memory
1109367 2024-11-06T15:05:57 Z classic Tracks in the Snow (BOI13_tracks) C++17
9.375 / 100
493 ms 112092 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 && 
				snow[nextRow][nextColumn] != '.' && 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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1616 KB Output isn't correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Correct 6 ms 1360 KB Output is correct
5 Incorrect 2 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 592 KB Output isn't correct
11 Correct 2 ms 592 KB Output is correct
12 Incorrect 3 ms 940 KB Output isn't correct
13 Incorrect 3 ms 848 KB Output isn't correct
14 Incorrect 2 ms 848 KB Output isn't correct
15 Incorrect 7 ms 2180 KB Output isn't correct
16 Incorrect 8 ms 1616 KB Output isn't correct
17 Incorrect 7 ms 1688 KB Output isn't correct
18 Correct 5 ms 1632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 848 KB Output isn't correct
2 Incorrect 29 ms 9288 KB Output isn't correct
3 Incorrect 173 ms 87236 KB Output isn't correct
4 Incorrect 62 ms 20904 KB Output isn't correct
5 Incorrect 98 ms 48580 KB Output isn't correct
6 Incorrect 488 ms 94028 KB Output isn't correct
7 Incorrect 2 ms 848 KB Output isn't correct
8 Incorrect 2 ms 848 KB Output isn't correct
9 Incorrect 2 ms 624 KB Output isn't correct
10 Incorrect 1 ms 760 KB Output isn't correct
11 Incorrect 2 ms 1024 KB Output isn't correct
12 Incorrect 1 ms 504 KB Output isn't correct
13 Incorrect 31 ms 9288 KB Output isn't correct
14 Incorrect 18 ms 5012 KB Output isn't correct
15 Incorrect 13 ms 5580 KB Output isn't correct
16 Incorrect 15 ms 3700 KB Output isn't correct
17 Incorrect 82 ms 20560 KB Output isn't correct
18 Incorrect 49 ms 20304 KB Output isn't correct
19 Incorrect 55 ms 20880 KB Output isn't correct
20 Incorrect 41 ms 18256 KB Output isn't correct
21 Incorrect 99 ms 46968 KB Output isn't correct
22 Incorrect 105 ms 50396 KB Output isn't correct
23 Incorrect 164 ms 40468 KB Output isn't correct
24 Incorrect 92 ms 49232 KB Output isn't correct
25 Incorrect 190 ms 80968 KB Output isn't correct
26 Correct 247 ms 112092 KB Output is correct
27 Incorrect 333 ms 101612 KB Output isn't correct
28 Incorrect 493 ms 95184 KB Output isn't correct
29 Incorrect 451 ms 100868 KB Output isn't correct
30 Correct 409 ms 100000 KB Output is correct
31 Incorrect 407 ms 57004 KB Output isn't correct
32 Incorrect 378 ms 97512 KB Output isn't correct