結果

問題 No.2387 Yokan Factory
ユーザー hiro71687khiro71687k
提出日時 2023-07-23 21:48:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 461 ms / 5,000 ms
コード長 1,767 bytes
コンパイル時間 7,176 ms
コンパイル使用メモリ 270,476 KB
実行使用メモリ 13,192 KB
最終ジャッジ日時 2023-10-25 05:49:54
合計ジャッジ時間 11,363 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 258 ms
13,192 KB
testcase_16 AC 171 ms
12,164 KB
testcase_17 AC 366 ms
12,188 KB
testcase_18 AC 383 ms
11,088 KB
testcase_19 AC 243 ms
9,108 KB
testcase_20 AC 143 ms
8,508 KB
testcase_21 AC 461 ms
10,768 KB
testcase_22 AC 166 ms
8,076 KB
testcase_23 AC 386 ms
9,032 KB
testcase_24 AC 160 ms
8,348 KB
testcase_25 AC 176 ms
6,656 KB
testcase_26 AC 319 ms
9,736 KB
testcase_27 AC 191 ms
10,196 KB
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 4 ms
4,348 KB
testcase_30 AC 4 ms
4,348 KB
testcase_31 AC 3 ms
4,348 KB
testcase_32 AC 3 ms
4,348 KB
testcase_33 AC 3 ms
4,348 KB
testcase_34 AC 4 ms
4,348 KB
testcase_35 AC 4 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=998244353 ;
long long inf=10000999999999900;
int main(){
    ll n,m,x;
    cin >> n >> m >> x;
    vector<vector<pair<ll,pair<ll,long long>>>>g(n);
    for (ll i = 0; i < m; i++)
    {
        long long u,v,a,b;
        cin >> u >> v >> a >> b;
        u--,v--;
        g[u].push_back({v,{a,b}});
        g[v].push_back({u,{a,b}});
    }
    ll left=0,right=1000000001;
    while (right-left>1)
    {
        ll mid=(right+left)/2;
        priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>pq;
        pq.push({0,0});
        vector<long long>memo(n,inf);
        memo[0]=0;
        while (!pq.empty())
        {
            pair<ll,ll>p=pq.top();
            ll v=p.second;
            pq.pop();
            ll xx=p.first;
            if (memo[v]!=p.first)
            {
                continue;
            }
            
            if (memo[v]>=x)
            {
                continue;
            }
            
            for (ll j = 0; j < g[v].size(); j++)
            {
                if (g[v][j].second.second<mid)
                {
                    continue;
                }
                if (memo[g[v][j].first]>memo[v]+g[v][j].second.first)
                {
                    memo[g[v][j].first]=memo[v]+g[v][j].second.first;
                    pq.push({memo[g[v][j].first],g[v][j].first});
                }
            }
        }
        if (memo[n-1]>x)
        {
            right=mid;
        }else{
            left=mid;
        }
    }
    if (left==0)
    {
        cout << -1 << endl;
        return 0;
    }
    
    cout << left << endl;
}
0