Submission #1077144

# Submission time Handle Problem Language Result Execution time Memory
1077144 2024-08-27T01:43:36 Z ssitaram Tracks in the Snow (BOI13_tracks) C++17
19.7917 / 100
1048 ms 386300 KB
#include <bits/stdc++.h>
using namespace std;

const vector<int> dx = {-1, 1, 0, 0},
	  dy = {0, 0, -1, 1};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int h, w; cin >> h >> w;
	vector<string> grid(h);
	for (string& s : grid) cin >> s;
	deque<pair<int, pair<int, int>>> dq;
	dq.push_front({1, {0, 0}});
	vector<vector<bool>> vis(h, vector<bool>(w));
	int ans = 1;
	while (!dq.empty()) {
		int d = dq.front().first;
		pair<int, int> pla = dq.front().second;
		dq.pop_front();
		if (vis[pla.first][pla.second]) continue;
		vis[pla.first][pla.second] = true;
		ans = max(ans, d);
		for (int i = 0; i < 4; ++i) {
			pair<int, int> ne = {pla.first + dx[i], pla.second + dy[i]};
			if (ne.first < 0 || ne.first >= h || ne.second < 0 || ne.second >= w) continue;
			if (grid[pla.first][pla.second] == grid[ne.first][ne.second] && grid[ne.first][ne.second] != '.') {
				dq.push_front({d, ne});
			} else {
				dq.push_back({d + 1, ne});
			}
		}
	}
	cout << ans << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1116 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Correct 9 ms 1116 KB Output is correct
5 Incorrect 6 ms 648 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 3 ms 600 KB Output isn't correct
11 Correct 2 ms 604 KB Output is correct
12 Incorrect 7 ms 780 KB Output isn't correct
13 Incorrect 4 ms 604 KB Output isn't correct
14 Incorrect 5 ms 604 KB Output isn't correct
15 Incorrect 13 ms 1032 KB Output isn't correct
16 Incorrect 14 ms 1112 KB Output isn't correct
17 Incorrect 12 ms 952 KB Output isn't correct
18 Correct 9 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1116 KB Output isn't correct
2 Incorrect 77 ms 2756 KB Output isn't correct
3 Incorrect 784 ms 21072 KB Output isn't correct
4 Incorrect 173 ms 5444 KB Output isn't correct
5 Incorrect 301 ms 11608 KB Output isn't correct
6 Correct 1048 ms 72848 KB Output is correct
7 Incorrect 3 ms 1116 KB Output isn't correct
8 Incorrect 3 ms 1116 KB Output isn't correct
9 Incorrect 3 ms 860 KB Output isn't correct
10 Incorrect 1 ms 604 KB Output isn't correct
11 Incorrect 2 ms 860 KB Output isn't correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Incorrect 76 ms 2652 KB Output isn't correct
14 Incorrect 45 ms 1628 KB Output isn't correct
15 Incorrect 43 ms 1624 KB Output isn't correct
16 Incorrect 31 ms 1372 KB Output isn't correct
17 Incorrect 191 ms 5980 KB Output isn't correct
18 Incorrect 160 ms 5464 KB Output isn't correct
19 Incorrect 174 ms 5440 KB Output isn't correct
20 Incorrect 140 ms 4956 KB Output isn't correct
21 Incorrect 438 ms 12436 KB Output isn't correct
22 Incorrect 299 ms 11784 KB Output isn't correct
23 Incorrect 385 ms 10540 KB Output isn't correct
24 Incorrect 451 ms 11868 KB Output isn't correct
25 Incorrect 788 ms 20920 KB Output isn't correct
26 Correct 986 ms 386300 KB Output is correct
27 Correct 959 ms 106232 KB Output is correct
28 Correct 1025 ms 72956 KB Output is correct
29 Correct 1010 ms 66244 KB Output is correct
30 Correct 959 ms 91164 KB Output is correct
31 Incorrect 600 ms 15520 KB Output isn't correct
32 Incorrect 1008 ms 119340 KB Output isn't correct