Submission #590118

# Submission time Handle Problem Language Result Execution time Memory
590118 2022-07-05T14:34:58 Z Minhho Tracks in the Snow (BOI13_tracks) C++17
Compilation error
0 ms 0 KB
#define taskname "1"
#include <bits/stdc++.h>
#define iii tuple<int,int,int>

using namespace std;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}, maxn = 4010;
int a[maxn][maxn], dp[maxn][maxn], w, h;
deque<iii> dq;

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cin>>w>>h;
    char c;
    for (int i=1; i<=w; i++) for (int j=1; j<=h; j++) cin>>c, a[i][j] = c != '.' ? c : -1, dp[i][j] = maxn * maxn;
    dp[1][1] = 1;
    dq.emplace_back(1, 1, 1);
    while (!dq.empty())
    {
        auto [i, j, dij] = dq.front(); dq.pop_front();
        if (dij != d[i][j]) continue;
        for (int k=0; k<4; k++)
        {
            int ci = i + dx[k], cj = j + dy[k];
            if (val(ci, cj))
            {
                int wt = a[i][j] != a[ci][cj] && min(a[i][j], a[ci][cj]) != -1;
                if (dij + wt < dp[ci][cj])
                {
                    dp[ci][cj] = dij + wt;
                    if (wt) dq.emplace_back(ci, cj, dij+wt);
                    else dq.emplace_front(ci, cj, dij+wt);
                }
            }
        }
    }
    int ans = -1;
    for (int i=1; i<=w; i++) for (int j=1; j<=h; j++) ans = max(ans, dp[i][j]);
    cout<<ans;
}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:24:20: error: 'd' was not declared in this scope
   24 |         if (dij != d[i][j]) continue;
      |                    ^