Submission #1037007

# Submission time Handle Problem Language Result Execution time Memory
1037007 2024-07-27T21:34:30 Z sssamui Tracks in the Snow (BOI13_tracks) C++17
2.1875 / 100
177 ms 87376 KB
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;

vector<int> radd = { -1, 0, 1, 0 };
vector<int> cadd = { -1, 0, 1, 0 };

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int h, w;
	cin >> h >> w;
	vector<vector<char>> trk(h + 2, vector<char>(w + 2, '.'));
	for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) cin >> trk[i][j];

	priority_queue<pair<int, pair<int, int>>> bfs;
	int ans = 0;
	vector<vector<int>> dist(h + 2, vector<int>(w + 2, 0));
	if (trk[1][1] == '.') cout << 0;
	else
	{
		bfs.push({ -1, {1, 1} });
		while (!bfs.empty())
		{
			int nans = -bfs.top().first;
			int r = bfs.top().second.first;
			int c = bfs.top().second.second;
			bfs.pop();
			if (dist[r][c] == 0)
			{
				ans = nans;
				dist[r][c] = nans;
				for (int dir = 0; dir < 4; dir++)
				{
					if (trk[r + radd[dir]][c + cadd[dir]] == trk[r][c]) bfs.push({ -nans, {r + radd[dir], c + cadd[dir]} });
					else if (trk[r + radd[dir]][c + cadd[dir]] != '.') bfs.push({ -nans - 1, {r + radd[dir], c + cadd[dir]} });
				}
			}
		}

		cout << ans;
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1856 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 Incorrect 2 ms 1372 KB Output isn't correct
5 Incorrect 1 ms 860 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 1 ms 720 KB Output isn't correct
11 Incorrect 1 ms 604 KB Output isn't correct
12 Incorrect 1 ms 860 KB Output isn't correct
13 Incorrect 1 ms 860 KB Output isn't correct
14 Incorrect 1 ms 860 KB Output isn't correct
15 Incorrect 3 ms 1884 KB Output isn't correct
16 Incorrect 3 ms 1880 KB Output isn't correct
17 Incorrect 2 ms 1884 KB Output isn't correct
18 Incorrect 2 ms 1296 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 972 KB Output isn't correct
2 Incorrect 16 ms 9036 KB Output isn't correct
3 Incorrect 177 ms 87180 KB Output isn't correct
4 Incorrect 35 ms 20820 KB Output isn't correct
5 Incorrect 83 ms 49252 KB Output isn't correct
6 Incorrect 158 ms 87376 KB Output isn't correct
7 Incorrect 1 ms 860 KB Output isn't correct
8 Incorrect 1 ms 860 KB Output isn't correct
9 Incorrect 1 ms 860 KB Output isn't correct
10 Incorrect 1 ms 604 KB Output isn't correct
11 Incorrect 1 ms 980 KB Output isn't correct
12 Incorrect 1 ms 604 KB Output isn't correct
13 Incorrect 15 ms 9156 KB Output isn't correct
14 Incorrect 9 ms 5720 KB Output isn't correct
15 Incorrect 13 ms 6188 KB Output isn't correct
16 Incorrect 10 ms 3932 KB Output isn't correct
17 Incorrect 52 ms 22540 KB Output isn't correct
18 Incorrect 38 ms 22612 KB Output isn't correct
19 Incorrect 35 ms 20820 KB Output isn't correct
20 Incorrect 47 ms 19280 KB Output isn't correct
21 Incorrect 130 ms 51164 KB Output isn't correct
22 Incorrect 91 ms 49172 KB Output isn't correct
23 Incorrect 64 ms 42576 KB Output isn't correct
24 Incorrect 80 ms 49764 KB Output isn't correct
25 Incorrect 154 ms 87132 KB Output isn't correct
26 Correct 118 ms 67100 KB Output is correct
27 Incorrect 148 ms 87144 KB Output isn't correct
28 Incorrect 148 ms 87032 KB Output isn't correct
29 Incorrect 148 ms 87124 KB Output isn't correct
30 Incorrect 154 ms 85332 KB Output isn't correct
31 Incorrect 97 ms 56236 KB Output isn't correct
32 Incorrect 142 ms 87072 KB Output isn't correct