結果

問題 No.2366 登校
ユーザー 鴨志田卓
提出日時 2023-07-17 03:53:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,273 bytes
コンパイル時間 1,445 ms
コンパイル使用メモリ 174,240 KB
実行使用メモリ 25,172 KB
最終ジャッジ日時 2025-06-20 11:13:31
合計ジャッジ時間 5,356 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:35:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   35 |         auto [d, i, j, t] = q.top();
      |              ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
using pii = pair<int, int>;

const int N = 88, Z = N * 2;

int n, m, k, t;
pii g[N][N];

i64 dis[N][N][N * 4];

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

    cin >> n >> m >> k >> t;
    for(int i = 0, a, b, c, d; i < k; i ++) {
        cin >> a >> b >> c >> d;
        g[a][b] = {c, d}; 
    }

    memset(dis, 0x3f, sizeof dis);

    dis[1][1][Z] = 0;

    using dij = tuple<i64, int, int, int>;

    priority_queue<dij, vector<dij>, greater<dij> > q;

    q.push({0, 1, 1, Z});

    while(q.size()) {
        auto [d, i, j, t] = q.top();
        q.pop();

        if(dis[i][j][t] < d) continue;

        auto update = [&q](int x, int y, int z, i64 d) {
            if(x < 1 || x > n || y < 1 || y > m || z < 0 || z >= 4 * N) return;
            if(d < dis[x][y][z]) {
                dis[x][y][z] = d;
                q.push({d, x, y, z});
            }
        };

        update(i - 1, j, t + 1, d);
        update(i + 1, j, t + 1, d);
        update(i, j - 1, t + 1, d);
        update(i, j + 1, t + 1, d);
        update(i, j, t - g[i][j].first + 1, d + g[i][j].second);
    }

    cout << (dis[n][m][min(Z + t, 4 * N - 1)] <= 1e18 ? dis[n][m][min(Z + t, 4 * N - 1)] : -1);
}
0