# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
926707 | 2024-02-13T14:29:17 Z | htphong0909 | Tracks in the Snow (BOI13_tracks) | C++17 | 83 ms | 12764 KB |
#include<bits/stdc++.h> using namespace std; void File() { #define file "ZOO" freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout); } int n, m; bool visited[1001][1001]; char arr[1001][1001]; vector<pair<int, int>> dif, nDif; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, 1, 0, -1}; bool canGo(int x, int y) { return (x <= n && y <= m && min(x, y) > 0 && arr[x][y] != '.' && !visited[x][y]); } void dfs(int x, int y) { visited[x][y] = true; for (int i = 0; i < 4; i++) { int vx = x + dx[i]; int vy = y + dy[i]; if (canGo(vx, vy)) { if (arr[vx][vy] == arr[x][y]) dfs(vx, vy); else nDif.emplace_back(vx, vy); } } } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); //File(); cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> arr[i][j]; } } nDif.emplace_back(1, 1); int ans = 0; while (!nDif.empty()) { ans++; dif = nDif; nDif.clear(); for (pair<int, int> cur : dif) dfs(cur.first, cur.second); dif.clear(); } cout << ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 2392 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 8 ms | 3808 KB | Output is correct |
5 | Correct | 2 ms | 1116 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 604 KB | Output is correct |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Correct | 3 ms | 860 KB | Output is correct |
11 | Correct | 2 ms | 1864 KB | Output is correct |
12 | Correct | 6 ms | 1372 KB | Output is correct |
13 | Correct | 2 ms | 1188 KB | Output is correct |
14 | Correct | 2 ms | 1112 KB | Output is correct |
15 | Correct | 13 ms | 1944 KB | Output is correct |
16 | Correct | 15 ms | 2400 KB | Output is correct |
17 | Correct | 10 ms | 1848 KB | Output is correct |
18 | Correct | 8 ms | 3808 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 4444 KB | Execution killed with signal 11 |
2 | Incorrect | 16 ms | 3144 KB | Output isn't correct |
3 | Runtime error | 74 ms | 12616 KB | Execution killed with signal 11 |
4 | Incorrect | 36 ms | 5848 KB | Output isn't correct |
5 | Runtime error | 57 ms | 10324 KB | Execution killed with signal 11 |
6 | Runtime error | 83 ms | 12720 KB | Execution killed with signal 11 |
7 | Runtime error | 3 ms | 4440 KB | Execution killed with signal 11 |
8 | Runtime error | 3 ms | 4444 KB | Execution killed with signal 11 |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Incorrect | 1 ms | 604 KB | Output isn't correct |
11 | Runtime error | 3 ms | 4568 KB | Execution killed with signal 11 |
12 | Correct | 1 ms | 604 KB | Output is correct |
13 | Incorrect | 16 ms | 3164 KB | Output isn't correct |
14 | Correct | 26 ms | 3420 KB | Output is correct |
15 | Correct | 16 ms | 3416 KB | Output is correct |
16 | Incorrect | 14 ms | 1884 KB | Output isn't correct |
17 | Runtime error | 37 ms | 8412 KB | Execution killed with signal 11 |
18 | Incorrect | 35 ms | 6308 KB | Output isn't correct |
19 | Incorrect | 32 ms | 5888 KB | Output isn't correct |
20 | Incorrect | 30 ms | 5468 KB | Output isn't correct |
21 | Runtime error | 54 ms | 10372 KB | Execution killed with signal 11 |
22 | Runtime error | 54 ms | 10440 KB | Execution killed with signal 11 |
23 | Runtime error | 56 ms | 10576 KB | Execution killed with signal 11 |
24 | Runtime error | 52 ms | 10324 KB | Execution killed with signal 11 |
25 | Runtime error | 71 ms | 12436 KB | Execution killed with signal 11 |
26 | Runtime error | 62 ms | 11380 KB | Execution killed with signal 11 |
27 | Runtime error | 70 ms | 12608 KB | Execution killed with signal 11 |
28 | Runtime error | 77 ms | 12764 KB | Execution killed with signal 11 |
29 | Runtime error | 70 ms | 12620 KB | Execution killed with signal 11 |
30 | Runtime error | 71 ms | 12516 KB | Execution killed with signal 11 |
31 | Runtime error | 65 ms | 10840 KB | Execution killed with signal 11 |
32 | Runtime error | 73 ms | 12456 KB | Execution killed with signal 11 |