# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
445072 | 2021-07-16T11:03:51 Z | KazamaHoang | Tracks in the Snow (BOI13_tracks) | C++14 | 917 ms | 121740 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 = 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 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 | 4940 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 | 2892 KB | Output is correct |
13 | Correct | 4 ms | 2892 KB | Output is correct |
14 | Correct | 4 ms | 2892 KB | Output is correct |
15 | Correct | 14 ms | 4932 KB | Output is correct |
16 | Correct | 16 ms | 5196 KB | Output is correct |
17 | Correct | 12 ms | 4948 KB | Output is correct |
18 | Correct | 10 ms | 4940 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 30668 KB | Output isn't correct |
2 | Correct | 62 ms | 13384 KB | Output is correct |
3 | Correct | 394 ms | 46616 KB | Output is correct |
4 | Correct | 115 ms | 28984 KB | Output is correct |
5 | Incorrect | 152 ms | 24260 KB | Output isn't correct |
6 | Correct | 895 ms | 93004 KB | Output is correct |
7 | Correct | 17 ms | 32076 KB | Output is correct |
8 | Incorrect | 17 ms | 30668 KB | Output isn't correct |
9 | Correct | 3 ms | 580 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 17 ms | 31548 KB | Output is correct |
12 | Incorrect | 1 ms | 844 KB | Output isn't correct |
13 | Correct | 63 ms | 13492 KB | Output is correct |
14 | Correct | 35 ms | 9464 KB | Output is correct |
15 | Correct | 35 ms | 12040 KB | Output is correct |
16 | Correct | 27 ms | 5064 KB | Output is correct |
17 | Correct | 161 ms | 24808 KB | Output is correct |
18 | Correct | 133 ms | 31684 KB | Output is correct |
19 | Correct | 115 ms | 28996 KB | Output is correct |
20 | Correct | 92 ms | 17640 KB | Output is correct |
21 | Correct | 244 ms | 43536 KB | Output is correct |
22 | Incorrect | 144 ms | 24260 KB | Output isn't correct |
23 | Correct | 293 ms | 36168 KB | Output is correct |
24 | Correct | 238 ms | 36676 KB | Output is correct |
25 | Incorrect | 241 ms | 15892 KB | Output isn't correct |
26 | Correct | 917 ms | 118996 KB | Output is correct |
27 | Correct | 853 ms | 121740 KB | Output is correct |
28 | Correct | 863 ms | 93072 KB | Output is correct |
29 | Correct | 858 ms | 90464 KB | Output is correct |
30 | Correct | 858 ms | 97580 KB | Output is correct |
31 | Incorrect | 616 ms | 63392 KB | Output isn't correct |
32 | Correct | 860 ms | 101016 KB | Output is correct |