# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
484887 | 2021-11-05T17:19:12 Z | Olympia | Tracks in the Snow (BOI13_tracks) | C++17 | 1293 ms | 1048580 KB |
#include <vector> #include <iostream> #include <cassert> #include <cmath> #include <set> #include <map> #include <stack> #include <queue> #include <set> #include <algorithm> #include <iomanip> using namespace std; vector<vector<bool>> hasVisited; vector<string> grid; int R = 0; int B = 0; int cntr = 0; void dfs (int x, int y) { cntr++; //cout << cntr << endl; //cout << x << " " << y << endl; if (hasVisited[x][y]) { return; } hasVisited[x][y] = true; R += (grid[x][y] == 'R'); B += (grid[x][y] == 'F'); for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= 1; dy++) { if (dx + x >= 0 && dx + x < hasVisited.size() && dy + y >= 0 && dy + y < hasVisited[0].size() && grid[x + dx][y + dy] != '.' && abs(dx) + abs(dy) == 1 && !hasVisited[x + dx][y + dy]) { dfs(dx + x, dy + y); } } } } int main() { //freopen("milkorder.in", "r", stdin); int n, m; cin >> n >> m; hasVisited.resize(n), grid.resize(n); for (int i = 0; i < n; i++) { hasVisited[i].resize(m); cin >> grid[i]; for (int j = 0; j < m; j++) { hasVisited[i][j] = false; } } int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { //cout << i << " " << j << endl; if (!hasVisited[i][j] && grid[i][j] != '.') { dfs(i, j); ans += (bool)R + (bool)B; R = B = 0; } } } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 19108 KB | Output isn't correct |
2 | Incorrect | 1 ms | 204 KB | Output isn't correct |
3 | Incorrect | 1 ms | 332 KB | Output isn't correct |
4 | Incorrect | 17 ms | 12748 KB | Output isn't correct |
5 | Incorrect | 4 ms | 1484 KB | Output isn't correct |
6 | Incorrect | 0 ms | 204 KB | Output isn't correct |
7 | Incorrect | 1 ms | 332 KB | Output isn't correct |
8 | Incorrect | 1 ms | 588 KB | Output isn't correct |
9 | Incorrect | 1 ms | 332 KB | Output isn't correct |
10 | Incorrect | 3 ms | 1868 KB | Output isn't correct |
11 | Incorrect | 4 ms | 3404 KB | Output isn't correct |
12 | Incorrect | 10 ms | 6732 KB | Output isn't correct |
13 | Incorrect | 4 ms | 1484 KB | Output isn't correct |
14 | Incorrect | 4 ms | 1484 KB | Output isn't correct |
15 | Incorrect | 18 ms | 13200 KB | Output isn't correct |
16 | Incorrect | 24 ms | 19060 KB | Output isn't correct |
17 | Incorrect | 15 ms | 7460 KB | Output isn't correct |
18 | Incorrect | 16 ms | 12748 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1740 KB | Output isn't correct |
2 | Incorrect | 79 ms | 36988 KB | Output isn't correct |
3 | Incorrect | 611 ms | 265468 KB | Output isn't correct |
4 | Incorrect | 146 ms | 40292 KB | Output isn't correct |
5 | Incorrect | 541 ms | 373960 KB | Output isn't correct |
6 | Runtime error | 1036 ms | 1048580 KB | Execution killed with signal 9 |
7 | Incorrect | 3 ms | 1356 KB | Output isn't correct |
8 | Incorrect | 3 ms | 1740 KB | Output isn't correct |
9 | Incorrect | 4 ms | 1996 KB | Output isn't correct |
10 | Incorrect | 2 ms | 844 KB | Output isn't correct |
11 | Incorrect | 4 ms | 972 KB | Output isn't correct |
12 | Incorrect | 2 ms | 1200 KB | Output isn't correct |
13 | Incorrect | 76 ms | 37052 KB | Output isn't correct |
14 | Incorrect | 42 ms | 21820 KB | Output isn't correct |
15 | Incorrect | 54 ms | 25696 KB | Output isn't correct |
16 | Incorrect | 36 ms | 22132 KB | Output isn't correct |
17 | Incorrect | 183 ms | 93888 KB | Output isn't correct |
18 | Incorrect | 210 ms | 98676 KB | Output isn't correct |
19 | Incorrect | 139 ms | 40216 KB | Output isn't correct |
20 | Incorrect | 135 ms | 59588 KB | Output isn't correct |
21 | Incorrect | 340 ms | 148608 KB | Output isn't correct |
22 | Incorrect | 559 ms | 373888 KB | Output isn't correct |
23 | Incorrect | 360 ms | 183520 KB | Output isn't correct |
24 | Incorrect | 424 ms | 256900 KB | Output isn't correct |
25 | Incorrect | 872 ms | 398292 KB | Output isn't correct |
26 | Correct | 1293 ms | 982092 KB | Output is correct |
27 | Runtime error | 995 ms | 1048580 KB | Execution killed with signal 9 |
28 | Runtime error | 975 ms | 1048580 KB | Execution killed with signal 9 |
29 | Runtime error | 961 ms | 1048580 KB | Execution killed with signal 9 |
30 | Runtime error | 1016 ms | 1048580 KB | Execution killed with signal 9 |
31 | Incorrect | 1010 ms | 812132 KB | Output isn't correct |
32 | Runtime error | 1036 ms | 1048580 KB | Execution killed with signal 9 |