Submission #992097

# Submission time Handle Problem Language Result Execution time Memory
992097 2024-06-03T22:38:13 Z MladenP Tracks in the Snow (BOI13_tracks) C++17
51.875 / 100
2000 ms 1048576 KB
#include <iostream>
#include <string>

using namespace std;
const int MAXN = 4002;

int cx[4] = {+1, 0, -1, 0};
int cy[4] = { 0,-1,  0,+1};
string s[MAXN];
int dfs(int i, int j, char c) {
    int sol = 1;
    s[i][j] = (c == 'F' ? 'R':'F');
    for (int dir = 0; dir < 4; dir++) {
        if (s[i+cx[dir]][j+cy[dir]] == c) {
            sol += dfs(i+cx[dir], j+cy[dir], c);
        }
    }
    return sol;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int H, W; cin >> H >> W;
    s[0] = string(W+1, '#');
    for (int i = 1; i <= H; i++) {
        cin >> s[i];
        s[i] = '#' + s[i] + '#';
    }
    s[H+1] = string(W+1, '#');

    int prev = 0, cur, sol = 0;
    while((cur = dfs(1, 1, s[1][1])) != prev) {
        prev = cur;
        sol++;
    }
    cout << sol;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 105 ms 18512 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 576 KB Output is correct
4 Correct 16 ms 12972 KB Output is correct
5 Correct 22 ms 1624 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 24 ms 860 KB Output is correct
11 Correct 4 ms 3704 KB Output is correct
12 Correct 33 ms 6320 KB Output is correct
13 Correct 22 ms 1724 KB Output is correct
14 Correct 22 ms 1692 KB Output is correct
15 Correct 156 ms 4024 KB Output is correct
16 Correct 93 ms 18340 KB Output is correct
17 Correct 174 ms 6672 KB Output is correct
18 Correct 15 ms 12972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 455 ms 1620 KB Output is correct
2 Execution timed out 2033 ms 11600 KB Time limit exceeded
3 Execution timed out 2009 ms 48888 KB Time limit exceeded
4 Execution timed out 2021 ms 33364 KB Time limit exceeded
5 Execution timed out 2033 ms 28608 KB Time limit exceeded
6 Runtime error 1251 ms 1048576 KB Execution killed with signal 9
7 Correct 336 ms 1192 KB Output is correct
8 Correct 413 ms 1532 KB Output is correct
9 Correct 49 ms 1852 KB Output is correct
10 Correct 122 ms 1000 KB Output is correct
11 Correct 102 ms 912 KB Output is correct
12 Correct 526 ms 1264 KB Output is correct
13 Execution timed out 2057 ms 11432 KB Time limit exceeded
14 Correct 1667 ms 7228 KB Output is correct
15 Execution timed out 2039 ms 5712 KB Time limit exceeded
16 Correct 1919 ms 6228 KB Output is correct
17 Execution timed out 2039 ms 22752 KB Time limit exceeded
18 Execution timed out 2011 ms 14196 KB Time limit exceeded
19 Execution timed out 2020 ms 33648 KB Time limit exceeded
20 Execution timed out 2047 ms 12228 KB Time limit exceeded
21 Execution timed out 2105 ms 29520 KB Time limit exceeded
22 Execution timed out 2015 ms 28592 KB Time limit exceeded
23 Execution timed out 2017 ms 35088 KB Time limit exceeded
24 Execution timed out 2032 ms 29396 KB Time limit exceeded
25 Execution timed out 2009 ms 49492 KB Time limit exceeded
26 Correct 1240 ms 995512 KB Output is correct
27 Runtime error 801 ms 1048576 KB Execution killed with signal 9
28 Runtime error 1404 ms 1048576 KB Execution killed with signal 9
29 Runtime error 1190 ms 1048576 KB Execution killed with signal 9
30 Runtime error 917 ms 1048576 KB Execution killed with signal 9
31 Execution timed out 2031 ms 309588 KB Time limit exceeded
32 Execution timed out 2098 ms 900460 KB Time limit exceeded