답안 #1037010

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1037010 2024-07-27T21:40:21 Z sssamui Tracks in the Snow (BOI13_tracks) C++17
2.1875 / 100
232 ms 78992 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));
	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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1628 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 1112 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 604 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 2 ms 1628 KB Output isn't correct
16 Incorrect 3 ms 1628 KB Output isn't correct
17 Incorrect 2 ms 1628 KB Output isn't correct
18 Incorrect 2 ms 1116 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1112 KB Output isn't correct
2 Incorrect 23 ms 8184 KB Output isn't correct
3 Incorrect 150 ms 78968 KB Output isn't correct
4 Incorrect 35 ms 18768 KB Output isn't correct
5 Incorrect 87 ms 44984 KB Output isn't correct
6 Incorrect 150 ms 78992 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 604 KB Output isn't correct
10 Incorrect 1 ms 604 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 15 ms 8028 KB Output isn't correct
14 Incorrect 8 ms 4956 KB Output isn't correct
15 Incorrect 9 ms 5320 KB Output isn't correct
16 Incorrect 6 ms 3420 KB Output isn't correct
17 Incorrect 38 ms 20308 KB Output isn't correct
18 Incorrect 37 ms 20048 KB Output isn't correct
19 Incorrect 42 ms 18772 KB Output isn't correct
20 Incorrect 31 ms 17216 KB Output isn't correct
21 Incorrect 92 ms 46160 KB Output isn't correct
22 Incorrect 86 ms 44724 KB Output isn't correct
23 Incorrect 84 ms 38480 KB Output isn't correct
24 Incorrect 232 ms 45136 KB Output isn't correct
25 Incorrect 153 ms 78936 KB Output isn't correct
26 Correct 122 ms 60956 KB Output is correct
27 Incorrect 145 ms 78992 KB Output isn't correct
28 Incorrect 163 ms 78932 KB Output isn't correct
29 Incorrect 137 ms 78992 KB Output isn't correct
30 Incorrect 144 ms 77392 KB Output isn't correct
31 Incorrect 90 ms 50796 KB Output isn't correct
32 Incorrect 135 ms 78980 KB Output isn't correct