# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101411 | 2019-03-19T01:15:59 Z | shenxy | Tracks in the Snow (BOI13_tracks) | C++11 | 2000 ms | 47508 KB |
#include <cstdio> #include <algorithm> #include <queue> #include <cstring> #include <utility> using namespace std; typedef pair<int, int> coord; int dx[4] = {0, 0, 1, -1}; int dy[4] = {1, -1, 0, 0}; int main() { int H, W, numani = 0; scanf("%d %d", &H, &W); char mygrid[H][W]; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { scanf(" %c", &mygrid[i][j]); if (mygrid[i][j] != '.') numani += 1; } } char curani = mygrid[0][0]; int ans = 0; while (numani > 0) { bool visited[H][W]; memset(visited, false, sizeof(visited)); visited[0][0] = true; mygrid[0][0] = '?'; numani -= 1; queue<coord> bfsq; bfsq.push(coord(0, 0)); while (!bfsq.empty()) { coord k = bfsq.front(); bfsq.pop(); for (int i = 0; i < 4; i++) { if (k.first + dx[i] >= 0 && k.first + dx[i] < H && k.second + dy[i] >= 0 && k.second + dy[i] < W) { if (mygrid[k.first + dx[i]][k.second + dy[i]] == curani || mygrid[k.first + dx[i]][k.second + dy[i]] == '?') { if (!visited[k.first + dx[i]][k.second + dy[i]]) { visited[k.first + dx[i]][k.second + dy[i]] = true; bfsq.push(coord(k.first + dx[i], k.second + dy[i])); if (mygrid[k.first + dx[i]][k.second + dy[i]] != '?') { mygrid[k.first + dx[i]][k.second + dy[i]] = '?'; numani -= 1; } } } } } } ans += 1; if (curani == 'F') curani = 'R'; else curani = 'F'; } printf("%d", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 143 ms | 1024 KB | Output isn't correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Incorrect | 3 ms | 256 KB | Output isn't correct |
4 | Correct | 22 ms | 768 KB | Output is correct |
5 | Incorrect | 48 ms | 592 KB | Output isn't correct |
6 | Incorrect | 2 ms | 256 KB | Output isn't correct |
7 | Incorrect | 3 ms | 256 KB | Output isn't correct |
8 | Incorrect | 4 ms | 384 KB | Output isn't correct |
9 | Incorrect | 0 ms | 384 KB | Output isn't correct |
10 | Incorrect | 51 ms | 512 KB | Output isn't correct |
11 | Correct | 11 ms | 384 KB | Output is correct |
12 | Incorrect | 54 ms | 512 KB | Output isn't correct |
13 | Incorrect | 67 ms | 512 KB | Output isn't correct |
14 | Incorrect | 53 ms | 632 KB | Output isn't correct |
15 | Incorrect | 358 ms | 1024 KB | Output isn't correct |
16 | Incorrect | 152 ms | 1024 KB | Output isn't correct |
17 | Incorrect | 316 ms | 1024 KB | Output isn't correct |
18 | Correct | 24 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 504 ms | 604 KB | Output isn't correct |
2 | Execution timed out | 2040 ms | 4856 KB | Time limit exceeded |
3 | Execution timed out | 2055 ms | 47476 KB | Time limit exceeded |
4 | Execution timed out | 2057 ms | 11316 KB | Time limit exceeded |
5 | Execution timed out | 2055 ms | 26764 KB | Time limit exceeded |
6 | Execution timed out | 2040 ms | 47372 KB | Time limit exceeded |
7 | Incorrect | 446 ms | 504 KB | Output isn't correct |
8 | Incorrect | 539 ms | 384 KB | Output isn't correct |
9 | Incorrect | 119 ms | 632 KB | Output isn't correct |
10 | Incorrect | 185 ms | 436 KB | Output isn't correct |
11 | Incorrect | 210 ms | 384 KB | Output isn't correct |
12 | Incorrect | 407 ms | 384 KB | Output isn't correct |
13 | Execution timed out | 2059 ms | 4856 KB | Time limit exceeded |
14 | Execution timed out | 2040 ms | 2936 KB | Time limit exceeded |
15 | Execution timed out | 2036 ms | 3192 KB | Time limit exceeded |
16 | Execution timed out | 2025 ms | 2296 KB | Time limit exceeded |
17 | Execution timed out | 2021 ms | 12280 KB | Time limit exceeded |
18 | Execution timed out | 2044 ms | 12152 KB | Time limit exceeded |
19 | Execution timed out | 2058 ms | 11256 KB | Time limit exceeded |
20 | Execution timed out | 2056 ms | 10360 KB | Time limit exceeded |
21 | Execution timed out | 2041 ms | 27640 KB | Time limit exceeded |
22 | Execution timed out | 2024 ms | 26744 KB | Time limit exceeded |
23 | Execution timed out | 2036 ms | 23168 KB | Time limit exceeded |
24 | Execution timed out | 2053 ms | 26996 KB | Time limit exceeded |
25 | Execution timed out | 2028 ms | 47320 KB | Time limit exceeded |
26 | Correct | 1102 ms | 36328 KB | Output is correct |
27 | Execution timed out | 2016 ms | 47468 KB | Time limit exceeded |
28 | Execution timed out | 2033 ms | 47508 KB | Time limit exceeded |
29 | Execution timed out | 2017 ms | 47460 KB | Time limit exceeded |
30 | Execution timed out | 2007 ms | 46532 KB | Time limit exceeded |
31 | Execution timed out | 2033 ms | 30460 KB | Time limit exceeded |
32 | Execution timed out | 2028 ms | 47448 KB | Time limit exceeded |