# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
487613 | 2021-11-16T09:36:33 Z | KazamaHoang | Zoo (COCI19_zoo) | C++14 | 47 ms | 6212 KB |
#include <bits/stdc++.h> #define F first #define S second #define eb emplace_back #define bit(x, i) (((x) >> (i)) & 1) #define sz(x) ((int)x.size()) using namespace std; using ll = long long; const int inf = 1061109567; const ll INF = 4557430888798830399; const int MOD = 1e9 + 7; const int dx[] = {0, 1, -1, 0}; const int dy[] = {1, 0, 0, -1}; int numRow, numCol; char snow[1005][1005]; int dist[1005][1005]; bool outSide(int ux, int vy) { if (ux == 0 || ux == numRow + 1 || vy == 0 || vy == numCol + 1 || snow[ux][vy] == '*') return true; return false; } int main() { cin.tie(0)->sync_with_stdio(0); #define Task "" if (fopen(Task".in", "r")) { freopen(Task".in", "r", stdin); freopen(Task".out", "w", stdout); } cin >> numRow >> numCol; for (int i = 1; i <= numRow; ++ i) for (int j = 1; j <= numCol; ++ j) cin >> snow[i][j]; deque <pair <int, int>> dq; dq.push_back({1, 1}); dist[1][1] = 1; int res = 1; while (!dq.empty()) { int u = dq.front().F; int v = dq.front().S; dq.pop_front(); res = max(res, dist[u][v]); for (int i = 0; i <= 3; ++ i) { int ux = u + dx[i]; int vy = v + dy[i]; if (outSide(ux, vy) || dist[ux][vy] != 0) continue; if (snow[ux][vy] == snow[u][v]) { dq.push_front({ux, vy}); dist[ux][vy] = dist[u][v]; } else { dq.push_back({ux, vy}); dist[ux][vy] = dist[u][v] + 1; } } } cout << res; return 0; } // Written by Kazama Hoang ^^
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 0 ms | 464 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 720 KB | Output is correct |
6 | Correct | 1 ms | 848 KB | Output is correct |
7 | Correct | 1 ms | 848 KB | Output is correct |
8 | Correct | 1 ms | 720 KB | Output is correct |
9 | Correct | 1 ms | 720 KB | Output is correct |
10 | Correct | 1 ms | 848 KB | Output is correct |
11 | Correct | 1 ms | 720 KB | Output is correct |
12 | Correct | 1 ms | 720 KB | Output is correct |
13 | Correct | 1 ms | 720 KB | Output is correct |
14 | Correct | 1 ms | 720 KB | Output is correct |
15 | Correct | 1 ms | 720 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 0 ms | 464 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 720 KB | Output is correct |
6 | Correct | 1 ms | 848 KB | Output is correct |
7 | Correct | 1 ms | 848 KB | Output is correct |
8 | Correct | 1 ms | 720 KB | Output is correct |
9 | Correct | 1 ms | 720 KB | Output is correct |
10 | Correct | 1 ms | 848 KB | Output is correct |
11 | Correct | 1 ms | 720 KB | Output is correct |
12 | Correct | 1 ms | 720 KB | Output is correct |
13 | Correct | 1 ms | 720 KB | Output is correct |
14 | Correct | 1 ms | 720 KB | Output is correct |
15 | Correct | 1 ms | 720 KB | Output is correct |
16 | Correct | 16 ms | 6092 KB | Output is correct |
17 | Correct | 19 ms | 6128 KB | Output is correct |
18 | Correct | 22 ms | 6212 KB | Output is correct |
19 | Correct | 18 ms | 6164 KB | Output is correct |
20 | Correct | 17 ms | 6096 KB | Output is correct |
21 | Correct | 43 ms | 5940 KB | Output is correct |
22 | Correct | 44 ms | 5876 KB | Output is correct |
23 | Correct | 45 ms | 5964 KB | Output is correct |
24 | Correct | 46 ms | 6096 KB | Output is correct |
25 | Correct | 43 ms | 6096 KB | Output is correct |
26 | Correct | 43 ms | 5956 KB | Output is correct |
27 | Correct | 42 ms | 5968 KB | Output is correct |
28 | Correct | 44 ms | 5920 KB | Output is correct |
29 | Correct | 45 ms | 6192 KB | Output is correct |
30 | Correct | 47 ms | 6064 KB | Output is correct |