Submission #484886

# Submission time Handle Problem Language Result Execution time Memory
484886 2021-11-05T17:10:31 Z Olympia Tracks in the Snow (BOI13_tracks) C++17
2.1875 / 100
1513 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;
void dfs (int x, int y) {
    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()) {
                continue;
            }
            if (grid[x + dx][y + dy] != '.') {
                dfs(dx + x, dy + y);
            }
        }
    }
}
int main() {
    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++) {
            if (!hasVisited[i][j] && grid[i][j] != '.') {
                dfs(i, j);
                //cout << R << " " << B << '\n';
                //R = B = 0;
                ans += (bool)R + (bool)B;
            }
        }
    }
    cout << ans;
}

Compilation message

tracks.cpp: In function 'void dfs(int, int)':
tracks.cpp:27:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             if (dx + x < 0 || dx + x == hasVisited.size() || dy + y < 0 || dy + y == hasVisited[0].size()) {
      |                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~
tracks.cpp:27:83: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             if (dx + x < 0 || dx + x == hasVisited.size() || dy + y < 0 || dy + y == hasVisited[0].size()) {
      |                                                                            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 19264 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Incorrect 1 ms 292 KB Output isn't correct
4 Incorrect 17 ms 12748 KB Output isn't correct
5 Incorrect 5 ms 1612 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 5 ms 3532 KB Output isn't correct
12 Incorrect 12 ms 6860 KB Output isn't correct
13 Incorrect 5 ms 1612 KB Output isn't correct
14 Incorrect 4 ms 1612 KB Output isn't correct
15 Incorrect 22 ms 13244 KB Output isn't correct
16 Incorrect 29 ms 19300 KB Output isn't correct
17 Incorrect 18 ms 8292 KB Output isn't correct
18 Incorrect 18 ms 12736 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1716 KB Output isn't correct
2 Incorrect 78 ms 38084 KB Output isn't correct
3 Incorrect 618 ms 265556 KB Output isn't correct
4 Incorrect 151 ms 43584 KB Output isn't correct
5 Incorrect 521 ms 373808 KB Output isn't correct
6 Runtime error 1393 ms 1048576 KB Execution killed with signal 9
7 Incorrect 3 ms 1328 KB Output isn't correct
8 Incorrect 3 ms 1716 KB Output isn't correct
9 Incorrect 4 ms 2124 KB Output isn't correct
10 Incorrect 1 ms 844 KB Output isn't correct
11 Incorrect 3 ms 972 KB Output isn't correct
12 Incorrect 2 ms 1228 KB Output isn't correct
13 Incorrect 84 ms 38148 KB Output isn't correct
14 Incorrect 49 ms 21876 KB Output isn't correct
15 Incorrect 52 ms 25668 KB Output isn't correct
16 Incorrect 44 ms 22084 KB Output isn't correct
17 Incorrect 212 ms 95440 KB Output isn't correct
18 Incorrect 203 ms 98632 KB Output isn't correct
19 Incorrect 147 ms 43396 KB Output isn't correct
20 Incorrect 144 ms 59656 KB Output isn't correct
21 Incorrect 363 ms 149256 KB Output isn't correct
22 Incorrect 543 ms 373624 KB Output isn't correct
23 Incorrect 400 ms 187460 KB Output isn't correct
24 Incorrect 438 ms 257048 KB Output isn't correct
25 Incorrect 896 ms 404984 KB Output isn't correct
26 Correct 1513 ms 986436 KB Output is correct
27 Runtime error 1113 ms 1048580 KB Execution killed with signal 9
28 Runtime error 1119 ms 1048580 KB Execution killed with signal 9
29 Runtime error 1104 ms 1048580 KB Execution killed with signal 9
30 Runtime error 1093 ms 1048580 KB Execution killed with signal 9
31 Incorrect 1226 ms 822444 KB Output isn't correct
32 Runtime error 1171 ms 1048580 KB Execution killed with signal 9