結果

問題 No.1 道のショートカット
ユーザー sawfishsawfish
提出日時 2022-10-16 18:06:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,027 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 76,480 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-09 20:17:08
合計ジャッジ時間 3,255 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,380 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2 ms
4,380 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,376 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 ans = INF;

    que.push(P{1, 0, 0});

    while (!que.empty()) {
        auto p = que.front();
        que.pop();
        if (p.pos == N) {
            ans = min(ans, p.elapse);
            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});
            }
        }
    }

    cout << (ans != INF ? ans : -1) << endl;
}
0