Submission #445069

# Submission time Handle Problem Language Result Execution time Memory
445069 2021-07-16T11:02:01 Z KazamaHoang Tracks in the Snow (BOI13_tracks) C++14
0 / 100
900 ms 121664 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define eb emplace_back
#define bit(x, i) (((x) >> (i)) & 1)
#define sz(x) ((int)x.size())

using namespace std;
using ll = long long;

const int inf = 1061109567;
const ll INF = 4557430888798830399;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};

int numRow, numCol;
char snow[4005][4005];
int dist[4005][4005];

bool outSide(int ux, int vy) {
    if (ux == 0 || ux == numRow || vy == 0 || vy == numCol || snow[ux][vy] == '.')
        return true;
    return false;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    #define Task ""
    if (fopen(Task".in", "r")) {
        freopen(Task".in", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> numRow >> numCol;
    for (int i = 1; i <= numRow; ++ i)
        for (int j = 1; j <= numCol; ++ j)
            cin >> snow[i][j];
    deque <pair <int, int>> dq;
    dq.push_back({1, 1});
    dist[1][1] = 1;
    int res = 0;
    while (!dq.empty()) {
        int u = dq.front().F;
        int v = dq.front().S;
        dq.pop_front();
        for (int i = 0; i <= 3; ++ i) {
            int ux = u + dx[i];
            int vy = v + dy[i];
            if (outSide(ux, vy) || dist[ux][vy] != 0)
                continue;
            if (snow[ux][vy] == snow[u][v]) {
                dq.push_front({ux, vy});
                dist[ux][vy] = dist[u][v];
            } else {
                dq.push_back({ux, vy});
                dist[ux][vy] = dist[u][v] + 1;
            }
        }
    }
    cout << res;
    return 0;
}

// Written by Kazama Hoang ^^

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:31:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         freopen(Task".in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen(Task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 5196 KB Output isn't correct
2 Incorrect 1 ms 460 KB Output isn't correct
3 Incorrect 1 ms 716 KB Output isn't correct
4 Incorrect 9 ms 4972 KB Output isn't correct
5 Incorrect 4 ms 2892 KB Output isn't correct
6 Incorrect 1 ms 460 KB Output isn't correct
7 Incorrect 1 ms 716 KB Output isn't correct
8 Incorrect 1 ms 716 KB Output isn't correct
9 Incorrect 1 ms 1100 KB Output isn't correct
10 Incorrect 4 ms 2380 KB Output isn't correct
11 Incorrect 3 ms 2124 KB Output isn't correct
12 Incorrect 6 ms 2892 KB Output isn't correct
13 Incorrect 4 ms 2892 KB Output isn't correct
14 Incorrect 4 ms 2892 KB Output isn't correct
15 Incorrect 13 ms 4944 KB Output isn't correct
16 Incorrect 15 ms 5196 KB Output isn't correct
17 Incorrect 12 ms 4888 KB Output isn't correct
18 Incorrect 10 ms 4940 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 30668 KB Output isn't correct
2 Incorrect 59 ms 13508 KB Output isn't correct
3 Incorrect 403 ms 46652 KB Output isn't correct
4 Incorrect 111 ms 28996 KB Output isn't correct
5 Incorrect 144 ms 24056 KB Output isn't correct
6 Incorrect 834 ms 93064 KB Output isn't correct
7 Incorrect 16 ms 32076 KB Output isn't correct
8 Incorrect 16 ms 30684 KB Output isn't correct
9 Incorrect 2 ms 588 KB Output isn't correct
10 Incorrect 1 ms 332 KB Output isn't correct
11 Incorrect 17 ms 31452 KB Output isn't correct
12 Incorrect 1 ms 844 KB Output isn't correct
13 Incorrect 61 ms 13508 KB Output isn't correct
14 Incorrect 35 ms 9472 KB Output isn't correct
15 Incorrect 34 ms 12100 KB Output isn't correct
16 Incorrect 28 ms 5016 KB Output isn't correct
17 Incorrect 155 ms 24760 KB Output isn't correct
18 Incorrect 130 ms 31684 KB Output isn't correct
19 Incorrect 113 ms 29016 KB Output isn't correct
20 Incorrect 91 ms 17756 KB Output isn't correct
21 Incorrect 236 ms 43404 KB Output isn't correct
22 Incorrect 143 ms 24132 KB Output isn't correct
23 Incorrect 290 ms 36288 KB Output isn't correct
24 Incorrect 236 ms 36672 KB Output isn't correct
25 Incorrect 238 ms 15908 KB Output isn't correct
26 Incorrect 900 ms 119136 KB Output isn't correct
27 Incorrect 838 ms 121664 KB Output isn't correct
28 Incorrect 846 ms 93192 KB Output isn't correct
29 Incorrect 832 ms 90292 KB Output isn't correct
30 Incorrect 846 ms 97592 KB Output isn't correct
31 Incorrect 630 ms 63524 KB Output isn't correct
32 Incorrect 871 ms 101012 KB Output isn't correct