結果

問題 No.2387 Yokan Factory
ユーザー zezerozezero
提出日時 2023-07-22 15:55:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 382 ms / 5,000 ms
コード長 1,411 bytes
コンパイル時間 3,181 ms
コンパイル使用メモリ 177,068 KB
実行使用メモリ 13,188 KB
最終ジャッジ日時 2023-10-23 22:17:45
合計ジャッジ時間 8,158 ms
ジャッジサーバーID
(参考情報)
judge11 / 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 1 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 1 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 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 250 ms
13,188 KB
testcase_16 AC 167 ms
12,160 KB
testcase_17 AC 373 ms
12,184 KB
testcase_18 AC 225 ms
11,084 KB
testcase_19 AC 261 ms
9,100 KB
testcase_20 AC 225 ms
8,508 KB
testcase_21 AC 382 ms
10,764 KB
testcase_22 AC 209 ms
8,076 KB
testcase_23 AC 291 ms
9,036 KB
testcase_24 AC 152 ms
8,424 KB
testcase_25 AC 174 ms
6,652 KB
testcase_26 AC 326 ms
9,732 KB
testcase_27 AC 382 ms
10,444 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 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 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
  int n,m;
  ll x;
  cin >> n >> m >> x;
  vector<vector<pair<pair<int,ll>,ll>>> g(n);
  for (int i = 0; i < m;i++){
    int u,v;
    ll a,b;
    cin >> u >> v >> a >> b;
    g[v-1].push_back({{u-1,a},b});
    g[u-1].push_back({{v-1,a},b});
  }
  ll ok = -1,ng = 1e18+1LL;
  const ll INF = 1LL << 60;
  while(ng-ok > 1LL){
    ll mid = (ok+ng)/2;
    vector<ll> dist(n,INF);
    dist[0] = 0;
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> que;
    que.push({0,0});
    while(!que.empty()){
      auto [d,x] = que.top();
      que.pop();
      if (d > dist[x]) continue;
      for (auto [a,b]:g[x]){
        if (a.second +dist[x] <= dist[a.first] && b >= mid){
          dist[a.first] = dist[x]+a.second;
          que.push({dist[a.first],a.first});
        }
      }
    }
    //cout << mid << endl;
    //for (auto e:dist){
    //  if (e >= INF) cout << "F" << " ";
    //  else cout << e << " ";
    //}
    //cout << endl;
    if (dist[n-1] <= x){
      ok = mid;
    }
    else{
      ng = mid;
    }
  }
    cout << ok << endl;

  return 0;
}
0