結果

問題 No.2387 Yokan Factory
ユーザー Yuto TokunagaYuto Tokunaga
提出日時 2023-07-21 23:17:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,233 bytes
コンパイル時間 860 ms
コンパイル使用メモリ 85,132 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2023-10-21 23:17:48
合計ジャッジ時間 4,312 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,056 KB
testcase_01 AC 3 ms
6,056 KB
testcase_02 AC 3 ms
6,056 KB
testcase_03 AC 3 ms
6,060 KB
testcase_04 AC 3 ms
6,060 KB
testcase_05 AC 3 ms
6,060 KB
testcase_06 AC 3 ms
6,060 KB
testcase_07 AC 3 ms
6,060 KB
testcase_08 AC 3 ms
6,060 KB
testcase_09 AC 3 ms
6,060 KB
testcase_10 AC 3 ms
6,056 KB
testcase_11 AC 3 ms
6,056 KB
testcase_12 AC 3 ms
6,056 KB
testcase_13 AC 3 ms
6,056 KB
testcase_14 AC 3 ms
6,056 KB
testcase_15 AC 249 ms
11,264 KB
testcase_16 AC 168 ms
10,300 KB
testcase_17 AC 376 ms
10,700 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 231 ms
8,676 KB
testcase_21 AC 457 ms
9,672 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 7 ms
7,432 KB
testcase_26 AC 335 ms
9,208 KB
testcase_27 AC 10 ms
9,860 KB
testcase_28 AC 5 ms
6,120 KB
testcase_29 AC 6 ms
6,152 KB
testcase_30 AC 6 ms
6,140 KB
testcase_31 AC 5 ms
6,108 KB
testcase_32 AC 4 ms
6,084 KB
testcase_33 AC 4 ms
6,084 KB
testcase_34 AC 6 ms
6,148 KB
testcase_35 AC 5 ms
6,132 KB
testcase_36 AC 4 ms
6,084 KB
testcase_37 AC 3 ms
6,060 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'bool check(long long int)':
main.cpp:26:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   26 |         for(auto &[u, a, b] : G[v]) {
      |                   ^

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>

using namespace std;
using P = pair<long long,int>;
using T = tuple<int,int,int>;
const long long INF = 1e18;

int N, M, X;
vector<T> G[100005];
long long dist[100005];

bool check(long long mid) {
    fill(dist, dist+N+1, INF);
    priority_queue<P, vector<P>, greater<P> > que;
    dist[1] = 0;
    que.push(P(0, 1));

    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;
        for(auto &[u, a, b] : G[v]) {
            if(b < mid) continue;
            if(dist[u] > dist[v] + a) {
                dist[u] = dist[v] + a;
                que.push(P(dist[u], u));
            }
        }
    }
    return dist[N] <= X;
}

int main() {
    cin >> N >> M >> X;
    for(int i = 0; i < M; ++i) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        G[u].push_back(T(v, a, b));
        G[v].push_back(T(u, a, b));
    }
    
    long long l = 0, r = 1e18+1;
    while(r - l > 1) {
        long long mid = (l + r) / 2;
        if(check(mid)) l = mid;
        else r = mid;
    }
    if(l==0) cout << -1 << endl;
    else cout << l << endl;
    return 0;
}
0