Submission #811234

# Submission time Handle Problem Language Result Execution time Memory
811234 2023-08-07T02:55:52 Z andecaandeci Tracks in the Snow (BOI13_tracks) C++17
2.1875 / 100
2000 ms 20580 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

char grid[4005][4005], cur;
int h, w, n, cnt, ans = 0;

bool valid(int i, int j){
    return (i>=1 && i<=h && j>=1 && j<=w);
}

void dfs(int i, int j){
    cnt++;
    if(valid(i+1,j) && grid[i+1][j]==cur){
        grid[i+1][j] = (cur=='F' ? 'R' : 'F');
        dfs(i+1,j);
    }
    if(valid(i,j+1) && grid[i][j+1]==cur){
        grid[i][j+1] = (cur=='F' ? 'R' : 'F');
        dfs(i,j+1);
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>grid[i][j];
            if(grid[i][j] != '.') n++;
        }
    }
    if(grid[1][1] == '.') {
        cout<<"0\n";
        return 0;
    }


    while(cnt<n){
        cnt = 0;
        cur = grid[1][1];
        grid[1][1] = (cur=='F' ? 'R' : 'F');
        dfs(1,1);
        ++ans;
    }

    cout<<ans<<'\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 2079 ms 2388 KB Time limit exceeded
2 Execution timed out 2077 ms 340 KB Time limit exceeded
3 Execution timed out 2083 ms 468 KB Time limit exceeded
4 Incorrect 55 ms 2392 KB Output isn't correct
5 Execution timed out 2074 ms 1492 KB Time limit exceeded
6 Execution timed out 2062 ms 320 KB Time limit exceeded
7 Execution timed out 2064 ms 468 KB Time limit exceeded
8 Incorrect 1 ms 468 KB Output isn't correct
9 Execution timed out 2063 ms 724 KB Time limit exceeded
10 Execution timed out 2069 ms 1364 KB Time limit exceeded
11 Incorrect 4 ms 1108 KB Output isn't correct
12 Execution timed out 2088 ms 1492 KB Time limit exceeded
13 Execution timed out 2084 ms 1492 KB Time limit exceeded
14 Execution timed out 2078 ms 1492 KB Time limit exceeded
15 Execution timed out 2075 ms 2388 KB Time limit exceeded
16 Execution timed out 2044 ms 2392 KB Time limit exceeded
17 Execution timed out 2061 ms 2260 KB Time limit exceeded
18 Incorrect 55 ms 2388 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2069 ms 15572 KB Time limit exceeded
2 Execution timed out 2051 ms 5496 KB Time limit exceeded
3 Execution timed out 2029 ms 16684 KB Time limit exceeded
4 Execution timed out 2054 ms 8064 KB Time limit exceeded
5 Execution timed out 2045 ms 12752 KB Time limit exceeded
6 Execution timed out 2047 ms 16712 KB Time limit exceeded
7 Execution timed out 2079 ms 16212 KB Time limit exceeded
8 Execution timed out 2086 ms 15568 KB Time limit exceeded
9 Execution timed out 2068 ms 340 KB Time limit exceeded
10 Execution timed out 2076 ms 340 KB Time limit exceeded
11 Execution timed out 2078 ms 15876 KB Time limit exceeded
12 Execution timed out 2083 ms 852 KB Time limit exceeded
13 Execution timed out 2037 ms 5780 KB Time limit exceeded
14 Execution timed out 2066 ms 4276 KB Time limit exceeded
15 Execution timed out 2045 ms 4684 KB Time limit exceeded
16 Execution timed out 2072 ms 2132 KB Time limit exceeded
17 Execution timed out 2067 ms 8784 KB Time limit exceeded
18 Execution timed out 2025 ms 8668 KB Time limit exceeded
19 Execution timed out 2059 ms 8256 KB Time limit exceeded
20 Execution timed out 2061 ms 9620 KB Time limit exceeded
21 Execution timed out 2089 ms 17088 KB Time limit exceeded
22 Execution timed out 2043 ms 16696 KB Time limit exceeded
23 Execution timed out 2082 ms 14668 KB Time limit exceeded
24 Execution timed out 2078 ms 17072 KB Time limit exceeded
25 Execution timed out 2054 ms 20580 KB Time limit exceeded
26 Correct 171 ms 18536 KB Output is correct
27 Incorrect 620 ms 20484 KB Output isn't correct
28 Execution timed out 2085 ms 20368 KB Time limit exceeded
29 Execution timed out 2029 ms 20452 KB Time limit exceeded
30 Execution timed out 2020 ms 20404 KB Time limit exceeded
31 Execution timed out 2037 ms 17172 KB Time limit exceeded
32 Execution timed out 2017 ms 20540 KB Time limit exceeded