結果

問題 No.2387 Yokan Factory
ユーザー hiro71687khiro71687k
提出日時 2023-07-23 21:39:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,576 bytes
コンパイル時間 4,465 ms
コンパイル使用メモリ 271,068 KB
実行使用メモリ 16,644 KB
最終ジャッジ日時 2023-10-25 05:40:20
合計ジャッジ時間 11,903 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
16,644 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 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 260 ms
12,412 KB
testcase_16 AC 207 ms
11,912 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

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 ;
ld inf=10000999999999900;
int main(){
    ll n,m,x;
    cin >> n >> m >> x;
    vector<vector<pair<ll,pair<ll,ll>>>>g(n);
    for (ll i = 0; i < m; i++)
    {
        ll 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=inf;
    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<ll>memo(n,inf);
        memo[0]=0;
        while (!pq.empty())
        {
            ll v=pq.top().second;
            pq.pop();
            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