제출 #985035

#제출 시각아이디문제언어결과실행 시간메모리
985035pannenkoekTracks in the Snow (BOI13_tracks)C++14
100 / 100
707 ms179456 KiB
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using ld = long double;
using pii = pair<ll, ll>;

const int MAXN = 4e3 + 5;
int h, w, dist[MAXN][MAXN];
char field[MAXN][MAXN];

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

    cin >> h >> w;
    fill(&dist[0][0], &dist[0][0] + MAXN * MAXN, -1);
    fill(&field[0][0], &field[0][0] + MAXN * MAXN, '.');

    rep(i, 0, h)
        rep(j, 0, w)
            cin >> field[i + 1][j + 1];

    deque<pii> d{{{1, 1}}};
    dist[1][1] = 1;
    int res = 0;
    while(!d.empty()){
        auto [i, j] = d.front();
        d.pop_front();
        res = dist[i][j];
        for(auto [di, dj]: vector<pii>{{1, 0}, {-1, 0}, {0, 1}, {0, -1}}){
            if(field[i + di][j + dj] == '.') continue;
            if(dist[i + di][j + dj] >= 0) continue;
            bool same = field[i + di][j + dj] == field[i][j]; 
            dist[i + di][j + dj] = dist[i][j] + !same;
            if(same) d.push_front({i + di, j + dj});
            else d.push_back({i + di, j + dj});
        }
    }
    cout << res << "\n";
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

tracks.cpp: In function 'int main()':
tracks.cpp:33:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |         auto [i, j] = d.front();
      |              ^
tracks.cpp:36:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   36 |         for(auto [di, dj]: vector<pii>{{1, 0}, {-1, 0}, {0, 1}, {0, -1}}){
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...