結果

問題 No.2366 登校
ユーザー 鴨志田卓鴨志田卓
提出日時 2023-07-17 03:53:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 369 ms / 4,000 ms
コード長 1,273 bytes
コンパイル時間 1,933 ms
コンパイル使用メモリ 176,648 KB
実行使用メモリ 25,128 KB
最終ジャッジ日時 2023-09-03 03:01:41
合計ジャッジ時間 5,838 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
24,656 KB
testcase_01 AC 9 ms
24,620 KB
testcase_02 AC 8 ms
24,676 KB
testcase_03 AC 9 ms
24,656 KB
testcase_04 AC 8 ms
24,596 KB
testcase_05 AC 9 ms
24,624 KB
testcase_06 AC 9 ms
24,656 KB
testcase_07 AC 9 ms
24,748 KB
testcase_08 AC 9 ms
24,680 KB
testcase_09 AC 10 ms
24,684 KB
testcase_10 AC 9 ms
24,628 KB
testcase_11 AC 8 ms
24,588 KB
testcase_12 AC 177 ms
24,800 KB
testcase_13 AC 169 ms
25,008 KB
testcase_14 AC 174 ms
24,908 KB
testcase_15 AC 179 ms
24,856 KB
testcase_16 AC 178 ms
25,128 KB
testcase_17 AC 178 ms
24,860 KB
testcase_18 AC 174 ms
24,804 KB
testcase_19 AC 179 ms
24,940 KB
testcase_20 AC 176 ms
24,852 KB
testcase_21 AC 174 ms
24,916 KB
testcase_22 AC 149 ms
24,768 KB
testcase_23 AC 122 ms
24,880 KB
testcase_24 AC 122 ms
25,020 KB
testcase_25 AC 368 ms
25,048 KB
testcase_26 AC 369 ms
24,828 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:35:14: 警告: 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