結果
問題 | No.1607 Kth Maximum Card |
ユーザー | sash0 |
提出日時 | 2021-07-16 22:51:23 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,098 ms / 3,500 ms |
コード長 | 2,910 bytes |
コンパイル時間 | 2,688 ms |
コンパイル使用メモリ | 232,320 KB |
実行使用メモリ | 16,304 KB |
最終ジャッジ日時 | 2023-09-20 15:15:26 |
合計ジャッジ時間 | 12,386 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,384 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 1,098 ms
15,876 KB |
testcase_09 | AC | 804 ms
13,748 KB |
testcase_10 | AC | 1,061 ms
16,304 KB |
testcase_11 | AC | 141 ms
6,076 KB |
testcase_12 | AC | 739 ms
13,328 KB |
testcase_13 | AC | 47 ms
5,072 KB |
testcase_14 | AC | 48 ms
5,488 KB |
testcase_15 | AC | 281 ms
12,244 KB |
testcase_16 | AC | 43 ms
4,868 KB |
testcase_17 | AC | 18 ms
4,376 KB |
testcase_18 | AC | 161 ms
9,296 KB |
testcase_19 | AC | 104 ms
6,952 KB |
testcase_20 | AC | 194 ms
7,656 KB |
testcase_21 | AC | 173 ms
8,312 KB |
testcase_22 | AC | 384 ms
14,716 KB |
testcase_23 | AC | 399 ms
14,760 KB |
testcase_24 | AC | 108 ms
6,712 KB |
testcase_25 | AC | 65 ms
5,516 KB |
testcase_26 | AC | 80 ms
5,928 KB |
testcase_27 | AC | 116 ms
6,924 KB |
testcase_28 | AC | 95 ms
6,252 KB |
testcase_29 | AC | 296 ms
9,896 KB |
testcase_30 | AC | 842 ms
14,288 KB |
testcase_31 | AC | 267 ms
9,308 KB |
testcase_32 | AC | 65 ms
8,776 KB |
testcase_33 | AC | 66 ms
9,016 KB |
testcase_34 | AC | 64 ms
8,764 KB |
testcase_35 | AC | 64 ms
8,564 KB |
ソースコード
// clang-format off #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define mp make_pair #define fst first #define snd second #define forn(i,n) for (int i = 0; i < int(n); i++) #define forn1(i,n) for (int i = 1; i <= int(n); i++) #define popcnt __builtin_popcountll #define ffs __builtin_ffsll #define ctz __builtin_ctzll #define clz __builtin_clz #define clzll __builtin_clzll #define all(a) (a).begin(), (a).end() using namespace std; using namespace __gnu_pbds; using uint = unsigned int; using ll = long long; using ull = unsigned long long; using pii = pair<int,int>; using pli = pair<ll,int>; using pil = pair<int,ll>; using pll = pair<ll,ll>; template <typename T> using vec = vector<T>; using vi = vec<int>; using vl = vec<ll>; template <typename T> using que = queue<T>; template <typename T> using deq = deque<T>; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template <typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>; template <typename T> T id(T b) {return b;}; template <typename T> void chmax(T &x, T y) {if (x < y) x = y;} template <typename T> void chmin(T &x, T y) {if (x > y) x = y;} template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); } template <typename T> bool getf(T flag, size_t i) { return (flag>>i) & 1; } template <typename T> T setf(T flag, size_t i) { return flag | (T(1)<<i); } template <typename T> T unsetf(T flag, size_t i) { return flag & ~(T(1)<<i); } void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); } // clang-format on struct edge { int to, cost; edge(int to, int cost) : to(to), cost(cost) { } }; using elem = pii; const int INF = TEN(8); int main() { fastio(); int n, m, k; cin >> n >> m >> k; vec<vec<edge>> g(n); forn(i, m) { int x, y, c; cin >> x >> y >> c; x--, y--; g[x].emplace_back(y, c); g[y].emplace_back(x, c); } int l = -1, r = 200000; while (r - l > 1) { int m = (l + r) / 2; priority_queue<elem, vec<elem>, greater<elem>> q; q.emplace(0, 0); vec<int> dist(n, INF); while (!q.empty()) { auto [x, i] = q.top(); q.pop(); if (dist[i] < x) { continue; } for (auto [j, c] : g[i]) { int y = x + (c > m ? 1 : 0); if (dist[j] > y) { dist[j] = y; q.emplace(y, j); } } } if (dist[n - 1] < k) { r = m; } else { l = m; } } cout << r << endl; return 0; }