結果

問題 No.2387 Yokan Factory
ユーザー wtz2333wtz2333
提出日時 2023-07-21 22:23:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,450 bytes
コンパイル時間 1,793 ms
コンパイル使用メモリ 183,788 KB
実行使用メモリ 13,356 KB
最終ジャッジ日時 2023-10-21 22:24:12
合計ジャッジ時間 8,473 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 198 ms
12,300 KB
testcase_17 AC 423 ms
13,248 KB
testcase_18 AC 558 ms
11,848 KB
testcase_19 AC 402 ms
9,340 KB
testcase_20 AC 290 ms
8,156 KB
testcase_21 AC 616 ms
11,504 KB
testcase_22 AC 276 ms
8,028 KB
testcase_23 AC 444 ms
9,396 KB
testcase_24 AC 281 ms
8,700 KB
testcase_25 AC 265 ms
6,880 KB
testcase_26 AC 529 ms
10,184 KB
testcase_27 AC 652 ms
11,148 KB
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 5 ms
4,348 KB
testcase_30 AC 4 ms
4,348 KB
testcase_31 AC 4 ms
4,348 KB
testcase_32 AC 3 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