結果

問題 No.2387 Yokan Factory
ユーザー as277575as277575
提出日時 2023-07-21 22:05:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 611 ms / 5,000 ms
コード長 2,206 bytes
コンパイル時間 1,279 ms
コンパイル使用メモリ 136,780 KB
実行使用メモリ 10,772 KB
最終ジャッジ日時 2023-10-21 22:06:11
合計ジャッジ時間 7,534 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 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 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 1 ms
4,348 KB
testcase_15 AC 189 ms
10,624 KB
testcase_16 AC 139 ms
10,452 KB
testcase_17 AC 529 ms
10,772 KB
testcase_18 AC 384 ms
9,568 KB
testcase_19 AC 455 ms
8,064 KB
testcase_20 AC 276 ms
7,052 KB
testcase_21 AC 529 ms
9,096 KB
testcase_22 AC 262 ms
7,048 KB
testcase_23 AC 480 ms
7,840 KB
testcase_24 AC 180 ms
7,428 KB
testcase_25 AC 256 ms
5,892 KB
testcase_26 AC 606 ms
8,532 KB
testcase_27 AC 611 ms
8,896 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 3 ms
4,348 KB
testcase_33 AC 2 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 <algorithm>
#include <bit>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <set>
#include <string>

using namespace::std;

template<typename T, typename U>
ostream& operator<< (ostream& o, const pair<T, U>& p) {
  o << "<" << p.first << ", " << p.second << ">";
  return o;
}

template <typename T>
ostream& operator<< (ostream& o, const vector<T>& v) {
 for (const auto& x : v) o << x << " ";
 return o;
}

template <typename T>
ostream& operator<< (ostream& o, const set<T>& v) {
 for (const auto& x : v) o << x << " ";
 return o;
}

template <typename T>
ostream& operator<< (ostream& o, const deque<T>& v) {
 for (const auto& x : v) o << x << " ";
 return o;
}

template <typename K, typename V>
ostream& operator<<(ostream& o, const unordered_map<K, V>& m) {
  o << "{";
  for (const auto& [k, v] : m)
    o << " " << k << ": " << v << ",";
  o << "}";
  return o;
}

template <typename T>
istream& operator>> (istream& i, vector<T>& v) {
  for (auto& x : v) i >> x;
  return i;
}

istream& operator>> (istream& i, pair<int, int>& p) {
  i >> p.first >> p.second;
  return i;
}



int main() {
  ios::sync_with_stdio(false);
  long long n, m, x;
  cin >> n >> m >> x;
  vector<vector<tuple<int, int, int>>> e(n + 1);
  for (int i = 0; i < m; ++i) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    e[u].push_back({v, a, b});
    e[v].push_back({u, a, b});
  }
  const long long inf = 1e18 + 7;
  long long a = 0, b = 1e9+7;
  while (a <= b) {
    //cerr << " a " << a << " b " << b << endl;
    long long mid = (a + b) / 2;
    vector<long long> dis(n + 1, inf);
    set<pair<long long, int>> q {{0, 1}};
    while (q.size()) {
      auto [d, u] = *q.begin();
      q.erase(q.begin());
      //cerr << " d " << d << " u " << u << endl;
      if (dis[u] < inf) continue;
      dis[u] = d;
      for (auto [v, l, w] : e[u])
        if (mid <= w && dis[v] == inf)
          q.insert({d + l, v});
    }
    if (dis[n] > x) b = mid - 1;
    else a = mid + 1;
  }
  cout << b << endl;
  
  return 0;
}


0