結果

問題 No.2387 Yokan Factory
ユーザー random contestantrandom contestant
提出日時 2023-07-21 21:42:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 351 ms / 5,000 ms
コード長 1,294 bytes
コンパイル時間 5,316 ms
コンパイル使用メモリ 271,672 KB
実行使用メモリ 12,428 KB
最終ジャッジ日時 2023-10-21 21:40:40
合計ジャッジ時間 8,459 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 1 ms
4,348 KB
testcase_06 AC 1 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 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 213 ms
12,428 KB
testcase_16 AC 145 ms
11,400 KB
testcase_17 AC 300 ms
12,216 KB
testcase_18 AC 213 ms
11,116 KB
testcase_19 AC 234 ms
9,112 KB
testcase_20 AC 220 ms
8,536 KB
testcase_21 AC 339 ms
10,592 KB
testcase_22 AC 193 ms
8,104 KB
testcase_23 AC 260 ms
9,072 KB
testcase_24 AC 144 ms
8,456 KB
testcase_25 AC 156 ms
6,684 KB
testcase_26 AC 297 ms
9,764 KB
testcase_27 AC 351 ms
10,476 KB
testcase_28 AC 3 ms
4,348 KB
testcase_29 AC 5 ms
4,348 KB
testcase_30 AC 4 ms
4,348 KB
testcase_31 AC 3 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 3 ms
4,348 KB
testcase_35 AC 3 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll,ll>;
#define pb push_back
#define int long long
#define double long double
#define INF (ll) 3e18
// Ctrl + Shift + B コンパイル
// Ctrl + C 中断
// ./m 実行


signed main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<vector<tuple<int,int,int>>> E(n);
  rep(i,m){
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    E[u].emplace_back(v, a, b);
    E[v].emplace_back(u, a, b);
  }
  int ok = -1;
  int ng = INF;
  while(ng - ok != 1){
    int mid = (ng + ok) / 2;
    vl dist(n, INF);
    dist[0] = 0;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.emplace(0, 0);
    while(pq.size()){
      auto [cost, now] = pq.top(); pq.pop();
      if (dist[now] != cost) continue;
      for(auto [to, a, b] : E[now]){
        if (b >= mid){
          if (dist[to] <= dist[now] + a) continue;
          dist[to] = dist[now] + a;
          pq.emplace(dist[to], to);
        }
      }
    }
    // cout << dist[n] << " " << mid << endl;
    if (dist[n-1] <= x) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}
0