# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
445070 | 2021-07-16T11:02:49 Z | KazamaHoang | Tracks in the Snow (BOI13_tracks) | C++17 | 898 ms | 121664 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[4005][4005]; int dist[4005][4005]; bool outSide(int ux, int vy) { if (ux == 0 || ux == numRow || vy == 0 || vy == numCol || 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 = 0; 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 | 16 ms | 5196 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 716 KB | Output is correct |
4 | Correct | 10 ms | 5040 KB | Output is correct |
5 | Correct | 4 ms | 2892 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Incorrect | 1 ms | 716 KB | Output isn't correct |
9 | Correct | 1 ms | 1100 KB | Output is correct |
10 | Correct | 4 ms | 2380 KB | Output is correct |
11 | Correct | 3 ms | 2124 KB | Output is correct |
12 | Correct | 6 ms | 3004 KB | Output is correct |
13 | Correct | 5 ms | 2892 KB | Output is correct |
14 | Correct | 5 ms | 2800 KB | Output is correct |
15 | Correct | 14 ms | 4936 KB | Output is correct |
16 | Correct | 16 ms | 5100 KB | Output is correct |
17 | Correct | 12 ms | 4912 KB | Output is correct |
18 | Correct | 10 ms | 4940 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 30588 KB | Output isn't correct |
2 | Correct | 61 ms | 13508 KB | Output is correct |
3 | Correct | 398 ms | 46624 KB | Output is correct |
4 | Correct | 113 ms | 28996 KB | Output is correct |
5 | Incorrect | 141 ms | 24032 KB | Output isn't correct |
6 | Correct | 866 ms | 93100 KB | Output is correct |
7 | Correct | 17 ms | 32076 KB | Output is correct |
8 | Incorrect | 16 ms | 30668 KB | Output isn't correct |
9 | Correct | 3 ms | 588 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 17 ms | 31496 KB | Output is correct |
12 | Incorrect | 1 ms | 844 KB | Output isn't correct |
13 | Correct | 63 ms | 13408 KB | Output is correct |
14 | Correct | 36 ms | 9540 KB | Output is correct |
15 | Correct | 33 ms | 12024 KB | Output is correct |
16 | Correct | 29 ms | 5072 KB | Output is correct |
17 | Correct | 159 ms | 24880 KB | Output is correct |
18 | Correct | 134 ms | 31676 KB | Output is correct |
19 | Correct | 115 ms | 29072 KB | Output is correct |
20 | Correct | 93 ms | 17692 KB | Output is correct |
21 | Correct | 241 ms | 43404 KB | Output is correct |
22 | Incorrect | 145 ms | 24116 KB | Output isn't correct |
23 | Correct | 297 ms | 36252 KB | Output is correct |
24 | Correct | 239 ms | 36604 KB | Output is correct |
25 | Incorrect | 252 ms | 16060 KB | Output isn't correct |
26 | Correct | 898 ms | 119088 KB | Output is correct |
27 | Correct | 862 ms | 121664 KB | Output is correct |
28 | Correct | 864 ms | 92960 KB | Output is correct |
29 | Correct | 855 ms | 90244 KB | Output is correct |
30 | Correct | 879 ms | 97528 KB | Output is correct |
31 | Incorrect | 632 ms | 63508 KB | Output isn't correct |
32 | Correct | 873 ms | 100856 KB | Output is correct |