# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
675782 | 2022-12-27T22:14:33 Z | NONTAC | Tracks in the Snow (BOI13_tracks) | C++11 | 53 ms | 564 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; int dx[4] = {0, 0, 1, -1}; int dy[4] = {1, -1, 0, 0}; int n, m; char grid[4002][4002]; int d[4002][4002]; int ans = 0; bool same(char c1, char c2) { if(c1 != c2) return true; return false; } int bfs(int si, int sj) { deque<ii> dq; d[si][sj] = 1; dq.push_front(ii(si, sj)); while(!dq.empty()){ int ui = dq.front().first, uj = dq.front().second; dq.pop_front(); ans = max(ans, d[ui][uj]); for(int i = 0; i < 4; i++){ int vi = ui + dx[i], vj = uj + dy[i]; int w = same(grid[ui][uj], grid[vi][vj]); if(vi < 1 || vi > n || vj < 1 || vj > m || grid[vi][vj] == '.') continue; if(d[vi][vj] == 0){ d[vi][vj] = d[ui][uj] + w; if(w == 0){ dq.push_front(ii(vi, vj)); } else{ dq.push_back(ii(vi, vj)); } } } } } int main() { freopen("test.in","r",stdin); freopen("test.out","w",stdout); cin>>n>>m; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin>>grid[i][j]; } } bfs(1, 1); cout<<ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 34 ms | 484 KB | Execution killed with signal 11 |
2 | Runtime error | 44 ms | 512 KB | Execution killed with signal 11 |
3 | Runtime error | 41 ms | 512 KB | Execution killed with signal 11 |
4 | Runtime error | 38 ms | 516 KB | Execution killed with signal 11 |
5 | Runtime error | 36 ms | 508 KB | Execution killed with signal 11 |
6 | Runtime error | 35 ms | 460 KB | Execution killed with signal 11 |
7 | Runtime error | 38 ms | 460 KB | Execution killed with signal 11 |
8 | Runtime error | 34 ms | 460 KB | Execution killed with signal 11 |
9 | Runtime error | 33 ms | 504 KB | Execution killed with signal 11 |
10 | Runtime error | 36 ms | 496 KB | Execution killed with signal 11 |
11 | Runtime error | 36 ms | 548 KB | Execution killed with signal 11 |
12 | Runtime error | 36 ms | 472 KB | Execution killed with signal 11 |
13 | Runtime error | 34 ms | 460 KB | Execution killed with signal 11 |
14 | Runtime error | 53 ms | 460 KB | Execution killed with signal 11 |
15 | Runtime error | 32 ms | 512 KB | Execution killed with signal 11 |
16 | Runtime error | 31 ms | 512 KB | Execution killed with signal 11 |
17 | Runtime error | 32 ms | 460 KB | Execution killed with signal 11 |
18 | Runtime error | 32 ms | 504 KB | Execution killed with signal 11 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 51 ms | 528 KB | Execution killed with signal 11 |
2 | Runtime error | 30 ms | 536 KB | Execution killed with signal 11 |
3 | Runtime error | 31 ms | 544 KB | Execution killed with signal 11 |
4 | Runtime error | 35 ms | 548 KB | Execution killed with signal 11 |
5 | Runtime error | 35 ms | 536 KB | Execution killed with signal 11 |
6 | Runtime error | 31 ms | 536 KB | Execution killed with signal 11 |
7 | Runtime error | 31 ms | 444 KB | Execution killed with signal 11 |
8 | Runtime error | 35 ms | 432 KB | Execution killed with signal 11 |
9 | Runtime error | 34 ms | 444 KB | Execution killed with signal 11 |
10 | Runtime error | 31 ms | 496 KB | Execution killed with signal 11 |
11 | Runtime error | 30 ms | 520 KB | Execution killed with signal 11 |
12 | Runtime error | 30 ms | 544 KB | Execution killed with signal 11 |
13 | Runtime error | 30 ms | 460 KB | Execution killed with signal 11 |
14 | Runtime error | 32 ms | 484 KB | Execution killed with signal 11 |
15 | Runtime error | 38 ms | 544 KB | Execution killed with signal 11 |
16 | Runtime error | 31 ms | 552 KB | Execution killed with signal 11 |
17 | Runtime error | 30 ms | 512 KB | Execution killed with signal 11 |
18 | Runtime error | 31 ms | 468 KB | Execution killed with signal 11 |
19 | Runtime error | 36 ms | 504 KB | Execution killed with signal 11 |
20 | Runtime error | 50 ms | 488 KB | Execution killed with signal 11 |
21 | Runtime error | 31 ms | 460 KB | Execution killed with signal 11 |
22 | Runtime error | 49 ms | 492 KB | Execution killed with signal 11 |
23 | Runtime error | 33 ms | 464 KB | Execution killed with signal 11 |
24 | Runtime error | 32 ms | 512 KB | Execution killed with signal 11 |
25 | Runtime error | 31 ms | 504 KB | Execution killed with signal 11 |
26 | Runtime error | 32 ms | 536 KB | Execution killed with signal 11 |
27 | Runtime error | 39 ms | 512 KB | Execution killed with signal 11 |
28 | Runtime error | 30 ms | 520 KB | Execution killed with signal 11 |
29 | Runtime error | 32 ms | 460 KB | Execution killed with signal 11 |
30 | Runtime error | 33 ms | 564 KB | Execution killed with signal 11 |
31 | Runtime error | 31 ms | 508 KB | Execution killed with signal 11 |
32 | Runtime error | 35 ms | 488 KB | Execution killed with signal 11 |