Submission #1037009

# Submission time Handle Problem Language Result Execution time Memory
1037009 2024-07-27T21:39:49 Z sssamui Tracks in the Snow (BOI13_tracks) C++17
2.1875 / 100
137 ms 18316 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];

	int ans = 0;
	vector<vector<bool>> vis(h + 2, vector<bool>(w + 2, false));
	queue<pair<int, int>> bfs;
	queue<pair<int, int>> nxt;
	bfs.push({ 1, 1 });
	vis[1][1] = true;
	while (!bfs.empty())
	{
		ans++;
		while (!bfs.empty())
		{
			int r = bfs.front().first, c = bfs.front().second;
			bfs.pop();
			for (int dir = 0; dir < 4; dir++) if (!vis[r + radd[dir]][c + cadd[dir]])
			{
				vis[r + radd[dir]][c + cadd[dir]] = true;
				if (trk[r + radd[dir]][c + cadd[dir]] == trk[r][c]) bfs.push({ r + radd[dir], c + cadd[dir] });
				else if (trk[r + radd[dir]][c + cadd[dir]] != '.') nxt.push({ r + radd[dir], c + cadd[dir] });
			}
		}

		while (!nxt.empty())
		{
			bfs.push(nxt.front());
			nxt.pop();
		}
	}

	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 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 1 ms 604 KB Output isn't correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 344 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 344 KB Output isn't correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Incorrect 1 ms 348 KB Output isn't correct
14 Incorrect 1 ms 348 KB Output isn't correct
15 Incorrect 2 ms 684 KB Output isn't correct
16 Incorrect 2 ms 604 KB Output isn't correct
17 Incorrect 2 ms 604 KB Output isn't correct
18 Incorrect 2 ms 604 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 860 KB Output isn't correct
2 Incorrect 12 ms 2140 KB Output isn't correct
3 Incorrect 129 ms 18316 KB Output isn't correct
4 Incorrect 39 ms 4720 KB Output isn't correct
5 Incorrect 76 ms 10412 KB Output isn't correct
6 Incorrect 127 ms 18256 KB Output isn't correct
7 Incorrect 2 ms 860 KB Output isn't correct
8 Incorrect 1 ms 860 KB Output isn't correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 0 ms 348 KB Output isn't correct
11 Incorrect 1 ms 860 KB Output isn't correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Incorrect 12 ms 2292 KB Output isn't correct
14 Incorrect 7 ms 1368 KB Output isn't correct
15 Incorrect 8 ms 1484 KB Output isn't correct
16 Incorrect 5 ms 1116 KB Output isn't correct
17 Incorrect 36 ms 5000 KB Output isn't correct
18 Incorrect 30 ms 4952 KB Output isn't correct
19 Incorrect 29 ms 4728 KB Output isn't correct
20 Incorrect 36 ms 4184 KB Output isn't correct
21 Incorrect 72 ms 10832 KB Output isn't correct
22 Incorrect 68 ms 10580 KB Output isn't correct
23 Incorrect 57 ms 9044 KB Output isn't correct
24 Incorrect 69 ms 10740 KB Output isn't correct
25 Incorrect 130 ms 18260 KB Output isn't correct
26 Correct 102 ms 14160 KB Output is correct
27 Incorrect 121 ms 18316 KB Output isn't correct
28 Incorrect 122 ms 18260 KB Output isn't correct
29 Incorrect 120 ms 18260 KB Output isn't correct
30 Incorrect 119 ms 17980 KB Output isn't correct
31 Incorrect 79 ms 11860 KB Output isn't correct
32 Incorrect 137 ms 18304 KB Output isn't correct