Submission #1026792

# Submission time Handle Problem Language Result Execution time Memory
1026792 2024-07-18T11:18:04 Z vjudge1 Tracks in the Snow (BOI13_tracks) C++17
0 / 100
889 ms 91044 KB
#include <bits/stdc++.h>
using namespace std;

int h, w;
char m[4000][4000];
queue<pair<int, int> > q;
int vis[4000][4000];
vector<pair<int, int> > dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

int main() {
    cin>>h>>w;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin>>m[h][w];
        }
    }
    int res = 1;
    char animal = m[0][0];
    bool finish = false;
    while(!finish) {
        q.push({0, 0});
        while(q.size()) {
            int y = q.front().first;
            int x = q.front().second;
            q.pop();
            finish = true; 
            if(vis[y][x] == res || animal != m[y][x])
                continue;
            vis[y][x] = res;
            m[y][x] = 'A';
            for(auto d : dir) {
                int newY = y + d.first;
                int newX = x + d.second;
                if(newY >= 0 && newY < h && newX >= 0 && newX < w && vis[newY][newX] != res)
                    if(m[y][x] == animal || m[y][x] == 'A')
                        q.push({newY, newX});
            }
        }
        res++;
    }
    cout<<res<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 7512 KB Output isn't correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Incorrect 1 ms 2652 KB Output isn't correct
4 Incorrect 9 ms 7260 KB Output isn't correct
5 Incorrect 7 ms 3932 KB Output isn't correct
6 Incorrect 1 ms 2396 KB Output isn't correct
7 Incorrect 1 ms 2652 KB Output isn't correct
8 Incorrect 1 ms 2652 KB Output isn't correct
9 Incorrect 1 ms 2908 KB Output isn't correct
10 Incorrect 5 ms 3584 KB Output isn't correct
11 Incorrect 3 ms 3420 KB Output isn't correct
12 Incorrect 6 ms 3932 KB Output isn't correct
13 Incorrect 7 ms 3932 KB Output isn't correct
14 Incorrect 5 ms 3932 KB Output isn't correct
15 Incorrect 14 ms 7764 KB Output isn't correct
16 Incorrect 14 ms 7516 KB Output isn't correct
17 Incorrect 13 ms 7516 KB Output isn't correct
18 Incorrect 9 ms 7260 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 32604 KB Output isn't correct
2 Incorrect 87 ms 19232 KB Output isn't correct
3 Incorrect 889 ms 91044 KB Output isn't correct
4 Incorrect 194 ms 35964 KB Output isn't correct
5 Incorrect 468 ms 68692 KB Output isn't correct
6 Incorrect 794 ms 90960 KB Output isn't correct
7 Incorrect 15 ms 33372 KB Output isn't correct
8 Incorrect 13 ms 32644 KB Output isn't correct
9 Incorrect 3 ms 2648 KB Output isn't correct
10 Incorrect 2 ms 2640 KB Output isn't correct
11 Incorrect 14 ms 33056 KB Output isn't correct
12 Incorrect 2 ms 3160 KB Output isn't correct
13 Incorrect 81 ms 19112 KB Output isn't correct
14 Incorrect 48 ms 14672 KB Output isn't correct
15 Incorrect 55 ms 15444 KB Output isn't correct
16 Incorrect 33 ms 9120 KB Output isn't correct
17 Incorrect 217 ms 38020 KB Output isn't correct
18 Incorrect 208 ms 37712 KB Output isn't correct
19 Incorrect 195 ms 35920 KB Output isn't correct
20 Incorrect 179 ms 32084 KB Output isn't correct
21 Incorrect 501 ms 70532 KB Output isn't correct
22 Incorrect 478 ms 68528 KB Output isn't correct
23 Incorrect 403 ms 58040 KB Output isn't correct
24 Incorrect 451 ms 69720 KB Output isn't correct
25 Incorrect 805 ms 91040 KB Output isn't correct
26 Incorrect 631 ms 80712 KB Output isn't correct
27 Incorrect 827 ms 90840 KB Output isn't correct
28 Incorrect 818 ms 90884 KB Output isn't correct
29 Incorrect 823 ms 90996 KB Output isn't correct
30 Incorrect 813 ms 90032 KB Output isn't correct
31 Incorrect 558 ms 73128 KB Output isn't correct
32 Incorrect 815 ms 90960 KB Output isn't correct