結果

問題 No.2387 Yokan Factory
ユーザー wtz2333wtz2333
提出日時 2023-07-21 22:28:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 859 ms / 5,000 ms
コード長 1,451 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 183,544 KB
実行使用メモリ 13,324 KB
最終ジャッジ日時 2023-10-21 22:27:40
合計ジャッジ時間 10,967 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 309 ms
13,324 KB
testcase_16 AC 204 ms
12,268 KB
testcase_17 AC 439 ms
13,216 KB
testcase_18 AC 753 ms
11,816 KB
testcase_19 AC 502 ms
9,308 KB
testcase_20 AC 355 ms
8,124 KB
testcase_21 AC 859 ms
11,472 KB
testcase_22 AC 297 ms
7,996 KB
testcase_23 AC 564 ms
9,364 KB
testcase_24 AC 321 ms
8,668 KB
testcase_25 AC 278 ms
6,848 KB
testcase_26 AC 678 ms
10,152 KB
testcase_27 AC 846 ms
11,116 KB
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 5 ms
4,348 KB
testcase_30 AC 5 ms
4,348 KB
testcase_31 AC 5 ms
4,348 KB
testcase_32 AC 4 ms
4,348 KB
testcase_33 AC 3 ms
4,348 KB
testcase_34 AC 5 ms
4,348 KB
testcase_35 AC 4 ms
4,348 KB
testcase_36 AC 3 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In lambda function:
main.cpp:38:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   38 |             for(auto [v,w]:e[u]){
      |                      ^

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
struct node{
    int u,v;
    ll a,b;
};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    ll X;
    cin >> n >> m >> X;
    std::vector<node> a(m);
    for(int i = 0;i < m;i ++){
        cin >> a[i].u >> a[i].v >> a[i].a >> a[i].b;
    }
    auto check = [&](int x)->bool{
        std::vector<std::vector<pair<int,ll>>> e;
        e.resize(n + 1);
        for(int i = 0;i < m;i ++){
            if(a[i].b >= x){
                e[a[i].u].push_back({a[i].v,a[i].a});
                e[a[i].v].push_back({a[i].u,a[i].a});
            }
        }
        vector<ll> dis(n + 1,1e18 + 7);
        std::vector<int> vis(n + 1);
        priority_queue<pair<ll,int>> q;
        dis[1] = 0;
        q.push({dis[1],1});
        while(!q.empty()){
            int u = q.top().second;
            q.pop();
            if(vis[u])continue;
            vis[u] = 1;
            for(auto [v,w]:e[u]){
                if(dis[v] > dis[u] + w){
                    dis[v] = dis[u] + w;
                    q.push({-dis[v],v});
                }
            }
        }
        if(dis[n] <= X){
            return true;
        }return false;
    };
    int l = 0,r = 1e9,ans = -1;
    while(l <= r){
        int mid = l + r >> 1;
        if(check(mid)){
            l = mid + 1;
            ans = mid;
        }else r = mid - 1;
    }
    cout << ans << "\n";
    return 0;
}
0