답안 #892863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
892863 2023-12-26T05:53:01 Z stdfloat Tracks in the Snow (BOI13_tracks) C++17
2.1875 / 100
1209 ms 1030544 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int n, m, ans;

bool tr1, tr2;

vector<string> a;

vector<vector<bool>> vis;

bool chk(int x, int y) {
    return 0 <= min(x, y) && x < n && y < m && !vis[x][y];
}

void dfs(int x, int y) {
    if (vis[x][y]) return;
    vis[x][y] = true;

    if (a[x][y] == 'R') {
        ans += tr1; tr1 = false;
    }
    else {
        ans += tr2; tr2 = false;
    }

    if (chk(x - 1, y)) dfs(x - 1, y);
    if (chk(x + 1, y)) dfs(x + 1, y);
    if (chk(x, y - 1)) dfs(x, y - 1);
    if (chk(x, y + 1)) dfs(x, y + 1);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    cin >> n >> m;

    a.assign(n, "");
    for (auto &i : a) cin >> i;

    vis.assign(n, vector<bool>(m, false));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (!chk(i, j)) continue;

            tr1 = tr2 = true;
            dfs(i, j);
        }
    }

    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 15964 KB Output isn't correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Incorrect 0 ms 604 KB Output isn't correct
4 Incorrect 9 ms 10332 KB Output isn't correct
5 Incorrect 5 ms 5724 KB Output isn't correct
6 Incorrect 0 ms 456 KB Output isn't correct
7 Incorrect 1 ms 604 KB Output isn't correct
8 Incorrect 1 ms 604 KB Output isn't correct
9 Incorrect 1 ms 860 KB Output isn't correct
10 Incorrect 4 ms 4444 KB Output isn't correct
11 Incorrect 3 ms 2920 KB Output isn't correct
12 Incorrect 6 ms 5912 KB Output isn't correct
13 Incorrect 5 ms 5724 KB Output isn't correct
14 Incorrect 5 ms 5724 KB Output isn't correct
15 Incorrect 16 ms 16472 KB Output isn't correct
16 Incorrect 16 ms 15960 KB Output isn't correct
17 Incorrect 15 ms 15708 KB Output isn't correct
18 Incorrect 9 ms 10408 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3956 KB Output isn't correct
2 Incorrect 105 ms 101072 KB Output isn't correct
3 Incorrect 1209 ms 1030420 KB Output isn't correct
4 Incorrect 244 ms 241868 KB Output isn't correct
5 Incorrect 618 ms 579908 KB Output isn't correct
6 Incorrect 1128 ms 1030428 KB Output isn't correct
7 Incorrect 3 ms 3516 KB Output isn't correct
8 Incorrect 3 ms 3932 KB Output isn't correct
9 Incorrect 4 ms 3932 KB Output isn't correct
10 Incorrect 2 ms 2140 KB Output isn't correct
11 Incorrect 4 ms 3676 KB Output isn't correct
12 Incorrect 2 ms 1884 KB Output isn't correct
13 Incorrect 133 ms 101140 KB Output isn't correct
14 Incorrect 61 ms 58696 KB Output isn't correct
15 Incorrect 64 ms 64852 KB Output isn't correct
16 Incorrect 46 ms 41708 KB Output isn't correct
17 Incorrect 270 ms 261696 KB Output isn't correct
18 Incorrect 277 ms 258132 KB Output isn't correct
19 Incorrect 249 ms 241956 KB Output isn't correct
20 Incorrect 223 ms 222060 KB Output isn't correct
21 Incorrect 665 ms 599576 KB Output isn't correct
22 Incorrect 637 ms 579800 KB Output isn't correct
23 Incorrect 573 ms 498768 KB Output isn't correct
24 Incorrect 646 ms 585648 KB Output isn't correct
25 Incorrect 1119 ms 1030228 KB Output isn't correct
26 Correct 837 ms 788892 KB Output is correct
27 Incorrect 1153 ms 1030544 KB Output isn't correct
28 Incorrect 1172 ms 1024408 KB Output isn't correct
29 Incorrect 1105 ms 1022104 KB Output isn't correct
30 Incorrect 1182 ms 1000784 KB Output isn't correct
31 Incorrect 753 ms 654764 KB Output isn't correct
32 Incorrect 1109 ms 1022032 KB Output isn't correct