답안 #592987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592987 2022-07-10T03:41:19 Z beaboss Tracks in the Snow (BOI13_tracks) C++14
2.1875 / 100
889 ms 79264 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
	int h, w;

	cin >> h >> w;

	vector<vector<char> > graph(h, vector<char>(w, 0));

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> graph[i][j];
		}
	}

	deque<vector<int> > bfs;

	bfs.push_back({0, 0});
	vector<vector<int> > dist(h, vector<int>(w, -1));
	dist[0][0] = 1;
	int ans = 0;
	vector<pair<int, int> > vec = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

	while (!bfs.empty()) {
		auto current = bfs.front();
		bfs.pop_front();
		ans = max(ans, dist[current[0]][current[1]]);
		// cout << current[0] << current[1] << dist[current[0]][current[1]] << endl;
		for (pair<int, int> val: vec) {
			int newx = newx;
			int newy = current[1] + val.second;
			if (newx >= 0 &&
				newx < h &&
				newy < w &&
				newy >= 0) {
				if (graph[newx][newy] == '.' || dist[newx][newy] != -1) continue;
				
				if (graph[newx][newy] == 
					graph[current[0]][current[1]]) {
					dist[newx][newy] = dist[current[0]][current[1]];
					bfs.push_front({newx, newy});
				} else {
					bfs.push_back({newx, newy});
					dist[newx][newy] = dist[current[0]][current[1]] + 1;
					
				}
			}
		}
	}

	cout << ans << endl;


}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:38:19: warning: 'newx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |     if (graph[newx][newy] == '.' || dist[newx][newy] != -1) continue;
      |                   ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 1748 KB Output isn't correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Incorrect 10 ms 1124 KB Output isn't correct
5 Incorrect 6 ms 724 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 4 ms 596 KB Output isn't correct
11 Incorrect 3 ms 468 KB Output isn't correct
12 Incorrect 6 ms 724 KB Output isn't correct
13 Incorrect 5 ms 724 KB Output isn't correct
14 Incorrect 6 ms 724 KB Output isn't correct
15 Incorrect 16 ms 1684 KB Output isn't correct
16 Incorrect 14 ms 1680 KB Output isn't correct
17 Incorrect 15 ms 1676 KB Output isn't correct
18 Incorrect 10 ms 1236 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 812 KB Output isn't correct
2 Incorrect 89 ms 8324 KB Output isn't correct
3 Incorrect 889 ms 79264 KB Output isn't correct
4 Incorrect 223 ms 19108 KB Output isn't correct
5 Incorrect 493 ms 44904 KB Output isn't correct
6 Incorrect 878 ms 79192 KB Output isn't correct
7 Incorrect 4 ms 896 KB Output isn't correct
8 Incorrect 4 ms 824 KB Output isn't correct
9 Incorrect 4 ms 568 KB Output isn't correct
10 Incorrect 4 ms 468 KB Output isn't correct
11 Incorrect 4 ms 820 KB Output isn't correct
12 Incorrect 2 ms 340 KB Output isn't correct
13 Incorrect 94 ms 8372 KB Output isn't correct
14 Incorrect 52 ms 4960 KB Output isn't correct
15 Incorrect 56 ms 5484 KB Output isn't correct
16 Incorrect 36 ms 3660 KB Output isn't correct
17 Incorrect 229 ms 20584 KB Output isn't correct
18 Incorrect 228 ms 20360 KB Output isn't correct
19 Incorrect 211 ms 19216 KB Output isn't correct
20 Incorrect 190 ms 17572 KB Output isn't correct
21 Incorrect 514 ms 46484 KB Output isn't correct
22 Incorrect 512 ms 44908 KB Output isn't correct
23 Incorrect 415 ms 38760 KB Output isn't correct
24 Incorrect 482 ms 45328 KB Output isn't correct
25 Incorrect 877 ms 79224 KB Output isn't correct
26 Correct 665 ms 60708 KB Output is correct
27 Incorrect 880 ms 78812 KB Output isn't correct
28 Incorrect 882 ms 78816 KB Output isn't correct
29 Incorrect 882 ms 78816 KB Output isn't correct
30 Incorrect 847 ms 77212 KB Output isn't correct
31 Incorrect 570 ms 50620 KB Output isn't correct
32 Incorrect 868 ms 78808 KB Output isn't correct