# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
749174 | 2023-05-27T12:54:58 Z | nonono | Tracks in the Snow (BOI13_tracks) | C++14 | 854 ms | 119248 KB |
#include "bits/stdc++.h" using namespace std; const int mxN = 4e3 + 10; const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, 1, -1}; int n, m; char a[mxN][mxN]; int dp[mxN][mxN]; bool inside(int x, int y){ return (x >= 1) && (x <= n) && (y >= 1) && (y <= m); } signed main(){ #define name "test" if(fopen(name".inp", "r")){ freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 1; i <= n; i ++){ for(int j = 1; j <= m; j ++){ cin >> a[i][j]; } } int res = 1; deque<pair<int, int>> dq; dq.push_front({1, 1}); dp[1][1] = 1; while(!dq.empty()){ pair<int, int> c = dq.front(); dq.pop_front(); res = max(res, dp[c.first][c.second]); for(int i = 0; i < 4; i ++){ int x = c.first + dx[i]; int y = c.second + dy[i]; if(inside(x, y) && a[x][y] == a[c.first][c.second] && dp[x][y] == 0){ dq.push_front({x, y}); dp[x][y] = dp[c.first][c.second]; } else if(inside(x, y) && a[x][y] != '.' && dp[x][y] == 0){ dq.push_back({x, y}); dp[x][y] = dp[c.first][c.second] + 1; } } } cout << res << "\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 5108 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 1 ms | 724 KB | Output is correct |
4 | Correct | 10 ms | 5012 KB | Output is correct |
5 | Correct | 3 ms | 2900 KB | Output is correct |
6 | Correct | 0 ms | 468 KB | Output is correct |
7 | Correct | 1 ms | 724 KB | Output is correct |
8 | Correct | 1 ms | 724 KB | Output is correct |
9 | Correct | 1 ms | 1108 KB | Output is correct |
10 | Correct | 4 ms | 2388 KB | Output is correct |
11 | Correct | 3 ms | 2132 KB | Output is correct |
12 | Correct | 8 ms | 2900 KB | Output is correct |
13 | Correct | 4 ms | 2900 KB | Output is correct |
14 | Correct | 4 ms | 2824 KB | Output is correct |
15 | Correct | 15 ms | 5064 KB | Output is correct |
16 | Correct | 21 ms | 5128 KB | Output is correct |
17 | Correct | 11 ms | 4948 KB | Output is correct |
18 | Correct | 10 ms | 5036 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 30804 KB | Output is correct |
2 | Correct | 56 ms | 13620 KB | Output is correct |
3 | Correct | 338 ms | 57636 KB | Output is correct |
4 | Correct | 95 ms | 29004 KB | Output is correct |
5 | Correct | 199 ms | 44524 KB | Output is correct |
6 | Correct | 784 ms | 92284 KB | Output is correct |
7 | Correct | 16 ms | 32212 KB | Output is correct |
8 | Correct | 17 ms | 30768 KB | Output is correct |
9 | Correct | 2 ms | 596 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 16 ms | 31516 KB | Output is correct |
12 | Correct | 1 ms | 1492 KB | Output is correct |
13 | Correct | 60 ms | 13532 KB | Output is correct |
14 | Correct | 33 ms | 9480 KB | Output is correct |
15 | Correct | 28 ms | 12120 KB | Output is correct |
16 | Correct | 29 ms | 5076 KB | Output is correct |
17 | Correct | 148 ms | 24744 KB | Output is correct |
18 | Correct | 108 ms | 31712 KB | Output is correct |
19 | Correct | 98 ms | 29060 KB | Output is correct |
20 | Correct | 85 ms | 22172 KB | Output is correct |
21 | Correct | 200 ms | 43460 KB | Output is correct |
22 | Correct | 200 ms | 44588 KB | Output is correct |
23 | Correct | 268 ms | 36124 KB | Output is correct |
24 | Correct | 197 ms | 40900 KB | Output is correct |
25 | Correct | 503 ms | 78776 KB | Output is correct |
26 | Correct | 504 ms | 119248 KB | Output is correct |
27 | Correct | 711 ms | 105464 KB | Output is correct |
28 | Correct | 854 ms | 92396 KB | Output is correct |
29 | Correct | 837 ms | 90904 KB | Output is correct |
30 | Correct | 776 ms | 95012 KB | Output is correct |
31 | Correct | 743 ms | 63436 KB | Output is correct |
32 | Correct | 622 ms | 90748 KB | Output is correct |