# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
222728 | 2020-04-13T22:07:49 Z | kingfran1907 | Zoo (COCI19_zoo) | C++14 | 53 ms | 6400 KB |
#include <bits/stdc++.h> #define X first #define Y second using namespace std; const int dx[] = {0, 0, 1, -1}; const int dy[] = {1, -1, 0, 0}; const int maxn = 1010; const int inf = 0x3f3f3f3f; int n, m; char niz[maxn][maxn]; deque< pair<int, int> > q; int dis[maxn][maxn]; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%s", niz+i); memset(dis, -1, sizeof dis); dis[0][0] = 1; q.push_back({0, 0}); while (!q.empty()) { int x = q.front().X; int y = q.front().Y; q.pop_front(); for (int i = 0; i < 4; i++) { int tx = x + dx[i]; int ty = y + dy[i]; if (tx < 0 || tx >= n || ty < 0 || ty >= m) continue; if (dis[tx][ty] != -1 || niz[tx][ty] == '*') continue; if (niz[tx][ty] == niz[x][y]) { dis[tx][ty] = dis[x][y]; q.push_front({tx, ty}); } else { dis[tx][ty] = dis[x][y] + 1; q.push_back({tx, ty}); } } } int sol = 0; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) sol = max(sol, dis[i][j]); printf("%d", sol); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 4352 KB | Output is correct |
2 | Correct | 7 ms | 4352 KB | Output is correct |
3 | Correct | 7 ms | 4352 KB | Output is correct |
4 | Correct | 7 ms | 4352 KB | Output is correct |
5 | Correct | 7 ms | 4480 KB | Output is correct |
6 | Correct | 7 ms | 4480 KB | Output is correct |
7 | Correct | 7 ms | 4480 KB | Output is correct |
8 | Correct | 7 ms | 4352 KB | Output is correct |
9 | Correct | 7 ms | 4352 KB | Output is correct |
10 | Correct | 8 ms | 4480 KB | Output is correct |
11 | Correct | 7 ms | 4436 KB | Output is correct |
12 | Correct | 7 ms | 4480 KB | Output is correct |
13 | Correct | 7 ms | 4352 KB | Output is correct |
14 | Correct | 7 ms | 4352 KB | Output is correct |
15 | Correct | 7 ms | 4352 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 4352 KB | Output is correct |
2 | Correct | 7 ms | 4352 KB | Output is correct |
3 | Correct | 7 ms | 4352 KB | Output is correct |
4 | Correct | 7 ms | 4352 KB | Output is correct |
5 | Correct | 7 ms | 4480 KB | Output is correct |
6 | Correct | 7 ms | 4480 KB | Output is correct |
7 | Correct | 7 ms | 4480 KB | Output is correct |
8 | Correct | 7 ms | 4352 KB | Output is correct |
9 | Correct | 7 ms | 4352 KB | Output is correct |
10 | Correct | 8 ms | 4480 KB | Output is correct |
11 | Correct | 7 ms | 4436 KB | Output is correct |
12 | Correct | 7 ms | 4480 KB | Output is correct |
13 | Correct | 7 ms | 4352 KB | Output is correct |
14 | Correct | 7 ms | 4352 KB | Output is correct |
15 | Correct | 7 ms | 4352 KB | Output is correct |
16 | Correct | 15 ms | 6272 KB | Output is correct |
17 | Correct | 17 ms | 6268 KB | Output is correct |
18 | Correct | 16 ms | 6400 KB | Output is correct |
19 | Correct | 18 ms | 6400 KB | Output is correct |
20 | Correct | 16 ms | 6272 KB | Output is correct |
21 | Correct | 43 ms | 6272 KB | Output is correct |
22 | Correct | 53 ms | 6144 KB | Output is correct |
23 | Correct | 48 ms | 6144 KB | Output is correct |
24 | Correct | 45 ms | 6272 KB | Output is correct |
25 | Correct | 44 ms | 6272 KB | Output is correct |
26 | Correct | 44 ms | 6144 KB | Output is correct |
27 | Correct | 44 ms | 6124 KB | Output is correct |
28 | Correct | 43 ms | 6144 KB | Output is correct |
29 | Correct | 47 ms | 6272 KB | Output is correct |
30 | Correct | 45 ms | 6272 KB | Output is correct |