結果

問題 No.1 道のショートカット
ユーザー sawfishsawfish
提出日時 2022-10-16 18:11:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,030 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 76,520 KB
実行使用メモリ 814,128 KB
最終ジャッジ日時 2023-09-09 20:20:15
合計ジャッジ時間 9,355 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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);
            continue;
        }
        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