Submission #770757

# Submission time Handle Problem Language Result Execution time Memory
770757 2023-07-01T21:30:10 Z xCqlibur Tracks in the Snow (BOI13_tracks) C++17
0 / 100
23 ms 3048 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

const int mxH=505, mxW=505;

int H, W;

char grid[mxH][mxW], rChange[4]={0, 1, 0, -1}, cChange[4]={1, 0, -1, 0};
bool vis[mxH][mxW];
vector<pair<int, int>> dir;

void floodfill(int r, int c, char curr) {
    stack<pair<int, int>> frontier;
    frontier.push({r, c});
    while(!frontier.empty()) {
        r=frontier.top().first;
        c=frontier.top().second;
        frontier.pop();
        if(r<0||r>=H||c<0||c>=W||vis[r][c]) {
            continue;
        }
        if(grid[r][c]!=curr&&grid[r][c]!='.') {
            dir.push_back({r, c});
            continue;
        }
        for(int i=0; i<4; ++i) {
            if(vis[r+rChange[i]][c+cChange[i]])
                continue;
            vis[r+rChange[i]][c+cChange[i]]=1;
            frontier.push({r+rChange[i], c+cChange[i]});
        }
    }
}

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

    cin >> H >> W;
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            cin >> grid[i][j];
        }
    }
    vis[0][0]=1;
    int ans=0;
    dir.push_back({0, 0});
    while(1) {
        if(dir.empty())
            break;
        for(pair<int, int> p : dir) {
            floodfill(p.first, p.second, grid[p.first][p.second]);
            dir.erase(remove(dir.begin(), dir.end(), p), dir.end());
        }
        ++ans;
    }
    cout << ans+1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 724 KB Output isn't correct
2 Incorrect 0 ms 328 KB Output isn't correct
3 Incorrect 0 ms 332 KB Output isn't correct
4 Incorrect 2 ms 724 KB Output isn't correct
5 Incorrect 1 ms 564 KB Output isn't correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Incorrect 0 ms 340 KB Output isn't correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 1 ms 468 KB Output isn't correct
11 Incorrect 1 ms 468 KB Output isn't correct
12 Incorrect 2 ms 468 KB Output isn't correct
13 Incorrect 1 ms 468 KB Output isn't correct
14 Incorrect 2 ms 480 KB Output isn't correct
15 Incorrect 3 ms 744 KB Output isn't correct
16 Incorrect 3 ms 724 KB Output isn't correct
17 Incorrect 3 ms 732 KB Output isn't correct
18 Incorrect 2 ms 724 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 984 KB Execution killed with signal 11
2 Runtime error 7 ms 1748 KB Execution killed with signal 11
3 Runtime error 21 ms 3048 KB Execution killed with signal 11
4 Runtime error 10 ms 2004 KB Execution killed with signal 11
5 Runtime error 15 ms 2212 KB Execution killed with signal 11
6 Runtime error 20 ms 2736 KB Execution killed with signal 11
7 Runtime error 1 ms 980 KB Execution killed with signal 11
8 Runtime error 1 ms 980 KB Execution killed with signal 11
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Runtime error 1 ms 980 KB Execution killed with signal 11
12 Incorrect 1 ms 340 KB Output isn't correct
13 Runtime error 8 ms 1772 KB Execution killed with signal 11
14 Runtime error 6 ms 1616 KB Execution killed with signal 11
15 Runtime error 6 ms 1620 KB Execution killed with signal 11
16 Incorrect 6 ms 1112 KB Output isn't correct
17 Runtime error 10 ms 2072 KB Execution killed with signal 11
18 Runtime error 10 ms 2076 KB Execution killed with signal 11
19 Runtime error 10 ms 1992 KB Execution killed with signal 11
20 Runtime error 10 ms 2080 KB Execution killed with signal 11
21 Runtime error 15 ms 2252 KB Execution killed with signal 11
22 Runtime error 15 ms 2204 KB Execution killed with signal 11
23 Runtime error 18 ms 2152 KB Execution killed with signal 11
24 Runtime error 14 ms 2144 KB Execution killed with signal 11
25 Runtime error 18 ms 2784 KB Execution killed with signal 11
26 Runtime error 17 ms 2304 KB Execution killed with signal 11
27 Runtime error 19 ms 2580 KB Execution killed with signal 11
28 Runtime error 19 ms 2848 KB Execution killed with signal 11
29 Runtime error 23 ms 2668 KB Execution killed with signal 11
30 Runtime error 18 ms 3036 KB Execution killed with signal 11
31 Runtime error 16 ms 2240 KB Execution killed with signal 11
32 Runtime error 18 ms 2644 KB Execution killed with signal 11