답안 #379284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
379284 2021-03-17T20:28:37 Z ruadhan Tracks in the Snow (BOI13_tracks) C++14
100 / 100
705 ms 121456 KB
#include <bits/stdc++.h>

using namespace std;


int dx[4]{1, -1, 0, 0}, dy[4]{0, 0, 1, -1};


int n, m, depth[4000][4000], ans = 1;

string snow[4000];


bool inside(int x, int y) {

	return (x > -1 && x < n && y > -1 && y < m && snow[x][y] != '.');

}


int main() {

	iostream::sync_with_stdio(false);

	cin.tie(0);


	cin >> n >> m;

	for (int i = 0; i < n; i++) cin >> snow[i];


	deque<pair<int, int>> q;

	q.push_back({0, 0});

	depth[0][0] = 1;


	while (q.size()) {

		pair<int, int> c = q.front();

		q.pop_front();

		ans = max(ans, depth[c.first][c.second]);


		for (int i = 0; i < 4; i++) {

			int x = c.first + dx[i], y = c.second + dy[i];

			if (inside(x, y) && depth[x][y] == 0) {

				if (snow[x][y] == snow[c.first][c.second]) {

					depth[x][y] = depth[c.first][c.second];

					q.push_front({x, y});

				} else {

					depth[x][y] = depth[c.first][c.second] + 1;

					q.push_back({x, y});

				}

			}

		}

	}


	cout << ans;

	return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 3692 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 9 ms 3564 KB Output is correct
5 Correct 3 ms 2028 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 620 KB Output is correct
8 Correct 1 ms 748 KB Output is correct
9 Correct 1 ms 876 KB Output is correct
10 Correct 3 ms 1644 KB Output is correct
11 Correct 3 ms 1516 KB Output is correct
12 Correct 6 ms 2028 KB Output is correct
13 Correct 3 ms 2028 KB Output is correct
14 Correct 3 ms 2028 KB Output is correct
15 Correct 11 ms 3436 KB Output is correct
16 Correct 14 ms 3692 KB Output is correct
17 Correct 10 ms 3564 KB Output is correct
18 Correct 8 ms 3436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 15852 KB Output is correct
2 Correct 44 ms 11244 KB Output is correct
3 Correct 220 ms 61932 KB Output is correct
4 Correct 75 ms 28288 KB Output is correct
5 Correct 189 ms 46212 KB Output is correct
6 Correct 705 ms 96644 KB Output is correct
7 Correct 14 ms 16524 KB Output is correct
8 Correct 14 ms 15852 KB Output is correct
9 Correct 2 ms 748 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 13 ms 16236 KB Output is correct
12 Correct 2 ms 1132 KB Output is correct
13 Correct 45 ms 11244 KB Output is correct
14 Correct 25 ms 7276 KB Output is correct
15 Correct 22 ms 9580 KB Output is correct
16 Correct 21 ms 4332 KB Output is correct
17 Correct 115 ms 24172 KB Output is correct
18 Correct 93 ms 30956 KB Output is correct
19 Correct 74 ms 28272 KB Output is correct
20 Correct 57 ms 21356 KB Output is correct
21 Correct 138 ms 45420 KB Output is correct
22 Correct 188 ms 46316 KB Output is correct
23 Correct 227 ms 38252 KB Output is correct
24 Correct 141 ms 42372 KB Output is correct
25 Correct 460 ms 82960 KB Output is correct
26 Correct 439 ms 121456 KB Output is correct
27 Correct 583 ms 109340 KB Output is correct
28 Correct 699 ms 96276 KB Output is correct
29 Correct 700 ms 94560 KB Output is correct
30 Correct 640 ms 98720 KB Output is correct
31 Correct 566 ms 65260 KB Output is correct
32 Correct 502 ms 94504 KB Output is correct