結果

問題 No.2387 Yokan Factory
ユーザー GoldIngotGoldIngot
提出日時 2023-07-21 21:39:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 686 ms / 5,000 ms
コード長 2,573 bytes
コンパイル時間 5,907 ms
コンパイル使用メモリ 271,408 KB
実行使用メモリ 13,928 KB
最終ジャッジ日時 2023-10-21 21:35:51
合計ジャッジ時間 11,142 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 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 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 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 291 ms
13,856 KB
testcase_16 AC 179 ms
12,800 KB
testcase_17 AC 392 ms
13,928 KB
testcase_18 AC 567 ms
12,456 KB
testcase_19 AC 421 ms
9,656 KB
testcase_20 AC 302 ms
8,424 KB
testcase_21 AC 670 ms
11,812 KB
testcase_22 AC 289 ms
8,264 KB
testcase_23 AC 497 ms
9,560 KB
testcase_24 AC 288 ms
8,976 KB
testcase_25 AC 281 ms
7,040 KB
testcase_26 AC 576 ms
10,408 KB
testcase_27 AC 686 ms
11,440 KB
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 6 ms
4,348 KB
testcase_30 AC 5 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 3 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define rep2ll(i,m,n) for(ll (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF60 = 1LL<<60;//1152921504606846976
const int INF30 = 1<<30;
using mint = modint998244353;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
using VM = vector<mint>;
using VVM = vector<VM>;
using VVVM = vector<VVM>;
using VD = vector<double>;
using VVD = vector<VD>;
using VVVD = vector<VVD>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m, x; cin>>n>>m>>x;
    VL u(m), v(m), a(m), b(m);
    rep(i,m) cin>>u[i]>>v[i]>>a[i]>>b[i], u[i]--, v[i]--;
    ll ok = -1, ng = 1000000001;
    while(ok+1<ng){
        ll c = (ok+ng)/2;
        WeightedGraph<ll> g(n);
        rep(i,m)if(b[i]>=c){
            g[u[i]].emplace_back(v[i], a[i]);
            g[v[i]].emplace_back(u[i], a[i]);
        }
        auto dist = dijkstra(g, 0);
        (dist[n-1]<=x?ok:ng) = c;
    }
    cout<<ok;
    
    return 0;
}
0