結果

問題 No.1 道のショートカット
ユーザー sawfishsawfish
提出日時 2022-10-16 17:16:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,107 bytes
コンパイル時間 695 ms
コンパイル使用メモリ 76,608 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-09 19:36:55
合計ジャッジ時間 2,668 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
4,380 KB
testcase_32 WA -
testcase_33 AC 2 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 2 ms
4,380 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

constexpr int INF = 1 << 29;

struct P {
    int pos;
    int cost;
    int elapse;
};

int S[1500];
int T[1500];
int Y[1500];
int M[1500];

int main() {
    int N, C, V;
    cin >> N >> C >> V;

    for (int i = 0; i < V; i++) cin >> S[i];
    for (int i = 0; i < V; i++) cin >> T[i];
    for (int i = 0; i < V; i++) cin >> Y[i];
    for (int i = 0; i < V; i++) cin >> M[i];

    vector<P> G[N + 1];
    for (int i = 0; i < V; i++) {
        G[S[i]].push_back(P{T[i], Y[i], M[i]});
    }


    queue<P> que;
    int elapse[N + 1];
    for (int &i: elapse) i = INF;

    que.push(P{1, 0, 0});
    elapse[1] = 0;

    while (!que.empty()) {
        auto p = que.front();
        que.pop();
        if (p.pos == N) break;
        for (auto q: G[p.pos]) {
            if (C >= p.cost + q.cost) {
                que.push(P{q.pos, p.cost + q.cost, p.elapse + q.elapse});
                elapse[q.pos] = min(elapse[q.pos], p.elapse + q.elapse);
            }
        }
    }

    cout << (elapse[N] != INF ? elapse[N] : -1) << endl;
}
0