Submission #1091499

# Submission time Handle Problem Language Result Execution time Memory
1091499 2024-09-21T03:03:07 Z ef10 Tracks in the Snow (BOI13_tracks) C++17
51.1458 / 100
632 ms 90368 KB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int H, W;
string M[4005];
bool v[4005][4005];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> M[i];
	}
	if (M[0][0] == '.') return 0;
	deque<pair<int,int> > q;
	q.push_back(make_pair(0,0));
	v[0][0] = true;
	int res = 1;
	char current = M[0][0];
	while (!q.empty()) {
		auto c = q.front();
		q.pop_front();
		if (M[c.first][c.second] != current) {
			res++;
			current = M[c.first][c.second];
		}
		for (auto i : {-1,1}) {
			for (auto j : {0,1}) {
				if (j==0) {
					if (((i < 0 && c.first > 0) || (i > 0 && c.first < W-1)) && !v[c.first+i][c.second] && M[c.first+i][c.second] != '.') {
						v[c.first+i][c.second] = true;
						if (M[c.first][c.second] == M[c.first+i][c.second]) {
							q.push_front(make_pair(c.first+i,c.second));
						} else {
							q.push_back(make_pair(c.first+i,c.second));
						}
					}
				} else {
					if (((i < 0 && c.second > 0) || (i > 0 && c.second < H-1)) && !v[c.first][c.second+i] && M[c.first][c.second+i] != '.') {
						v[c.first][c.second+i] = true;
						if (M[c.first][c.second] == M[c.first][c.second+i]) {
							q.push_front(make_pair(c.first,c.second+i));
						} else {
							q.push_back(make_pair(c.first,c.second+i));
						}
					}
				}
			}
		}
	}
	cout << res << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 3016 KB Output isn't correct
2 Correct 0 ms 568 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Incorrect 7 ms 2368 KB Output isn't correct
5 Correct 3 ms 1884 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Incorrect 1 ms 856 KB Output isn't correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 3 ms 1628 KB Output is correct
11 Correct 4 ms 1372 KB Output is correct
12 Incorrect 6 ms 1752 KB Output isn't correct
13 Correct 3 ms 1884 KB Output is correct
14 Correct 3 ms 1884 KB Output is correct
15 Correct 9 ms 3164 KB Output is correct
16 Incorrect 10 ms 3232 KB Output isn't correct
17 Incorrect 9 ms 3160 KB Output isn't correct
18 Incorrect 6 ms 2396 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Correct 44 ms 9168 KB Output is correct
3 Correct 314 ms 61756 KB Output is correct
4 Incorrect 88 ms 19024 KB Output isn't correct
5 Correct 206 ms 32236 KB Output is correct
6 Correct 632 ms 75724 KB Output is correct
7 Incorrect 1 ms 600 KB Output isn't correct
8 Incorrect 1 ms 600 KB Output isn't correct
9 Incorrect 1 ms 604 KB Output isn't correct
10 Incorrect 1 ms 604 KB Output isn't correct
11 Incorrect 2 ms 612 KB Output isn't correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 42 ms 9356 KB Output is correct
14 Incorrect 27 ms 7004 KB Output isn't correct
15 Correct 22 ms 7200 KB Output is correct
16 Incorrect 12 ms 2392 KB Output isn't correct
17 Incorrect 119 ms 19900 KB Output isn't correct
18 Correct 84 ms 19684 KB Output is correct
19 Incorrect 83 ms 19028 KB Output isn't correct
20 Incorrect 45 ms 10576 KB Output isn't correct
21 Incorrect 193 ms 33112 KB Output isn't correct
22 Correct 208 ms 32336 KB Output is correct
23 Incorrect 183 ms 25428 KB Output isn't correct
24 Incorrect 189 ms 35204 KB Output isn't correct
25 Correct 376 ms 61936 KB Output is correct
26 Correct 416 ms 89696 KB Output is correct
27 Correct 529 ms 90368 KB Output is correct
28 Correct 569 ms 75728 KB Output is correct
29 Correct 573 ms 76376 KB Output is correct
30 Incorrect 534 ms 81312 KB Output isn't correct
31 Incorrect 408 ms 35516 KB Output isn't correct
32 Correct 481 ms 79884 KB Output is correct