結果

問題 No.2387 Yokan Factory
ユーザー nononnonon
提出日時 2023-07-21 21:59:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,822 bytes
コンパイル時間 2,603 ms
コンパイル使用メモリ 220,020 KB
実行使用メモリ 16,648 KB
最終ジャッジ日時 2023-10-21 22:01:02
合計ジャッジ時間 10,401 ms
ジャッジサーバーID
(参考情報)
judge13 / 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 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 271 ms
12,404 KB
testcase_16 AC 182 ms
11,904 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>
using namespace std;
using ll = long long;
using db = long double;
using ch = char;
using bl = bool;
using st = string;
using pll = pair<ll,ll>;
using psl = pair<st,ll>;
using vst = vector<st>;
using vch = vector<ch>;
using vvch = vector<vch>;
using vbl = vector<bl>;
using vvbl = vector<vbl>;
using vdb = vector<db>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpsl = vector<psl>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vvvvi = vector<vvvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vvvvll = vector<vvvll>;
using vvvvvll = vector<vvvvll>;
#define all(A) A.begin(),A.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)

int main() {
    ll N,M,X;
    cin>>N>>M>>X;
    vector<vector<pair<ll,pll>>> G(N);
    rep(i,M){
        ll u,v,a,b;
        cin>>u>>v>>a>>b;
        u--,v--;
        G[u].push_back(make_pair(v,make_pair(a,b)));
        G[v].push_back(make_pair(u,make_pair(a,b)));
    }
    ll l=-1,r=1e10;
    vbl seen;
    vll dist;
    while(r-l>1){
        ll m=(l+r)/2;
        seen.assign(N,0);
        dist.assign(N,2e18);
        priority_queue<pll,vpll,greater<pll>> q;
        q.push(make_pair(0,0));
        dist[0]=0;
        while(!q.empty()){
            ll v=q.top().second;
            q.pop();
            for(auto p:G[v]){
                ll u=p.first,a=p.second.first,b=p.second.second;
                if(seen[u])continue;
                if(dist[u]>dist[v]+a && m<=b){
                    dist[u]=dist[v]+a;
                    q.push(make_pair(dist[u],u));
                }
            }
            seen[v]=1;
        }
        if(dist[N-1]<=X)l=m;
        else r=m;
    }
    cout << l << endl;
    return 0;
}
0