結果
問題 | No.1607 Kth Maximum Card |
ユーザー | hir355 |
提出日時 | 2021-07-16 22:51:07 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,616 ms / 3,500 ms |
コード長 | 2,787 bytes |
コンパイル時間 | 2,347 ms |
コンパイル使用メモリ | 217,344 KB |
実行使用メモリ | 24,100 KB |
最終ジャッジ日時 | 2023-09-20 15:16:22 |
合計ジャッジ時間 | 28,123 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,384 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 2,616 ms
22,860 KB |
testcase_09 | AC | 1,750 ms
18,952 KB |
testcase_10 | AC | 2,054 ms
22,784 KB |
testcase_11 | AC | 282 ms
7,692 KB |
testcase_12 | AC | 1,489 ms
18,400 KB |
testcase_13 | AC | 164 ms
6,172 KB |
testcase_14 | AC | 199 ms
7,752 KB |
testcase_15 | AC | 1,425 ms
20,172 KB |
testcase_16 | AC | 164 ms
6,992 KB |
testcase_17 | AC | 51 ms
4,376 KB |
testcase_18 | AC | 718 ms
15,304 KB |
testcase_19 | AC | 375 ms
10,824 KB |
testcase_20 | AC | 614 ms
12,740 KB |
testcase_21 | AC | 647 ms
13,764 KB |
testcase_22 | AC | 2,289 ms
24,100 KB |
testcase_23 | AC | 2,548 ms
24,036 KB |
testcase_24 | AC | 363 ms
9,548 KB |
testcase_25 | AC | 216 ms
7,300 KB |
testcase_26 | AC | 263 ms
8,072 KB |
testcase_27 | AC | 375 ms
10,268 KB |
testcase_28 | AC | 291 ms
8,872 KB |
testcase_29 | AC | 933 ms
15,440 KB |
testcase_30 | AC | 2,195 ms
23,236 KB |
testcase_31 | AC | 793 ms
14,352 KB |
testcase_32 | AC | 265 ms
16,184 KB |
testcase_33 | AC | 265 ms
16,104 KB |
testcase_34 | AC | 271 ms
16,216 KB |
testcase_35 | AC | 270 ms
16,192 KB |
ソースコード
#include <atcoder/modint> #include <bits/stdc++.h> using namespace std; using namespace atcoder; constexpr long long INF_LL = 2000000000000000000LL; constexpr int INF = 2000000000; constexpr long long MOD = 1000000007; #define all(x) x.begin(), x.end() #define REP(i, a, b) for(int i = a; i < b; i++) #define rep(i, n) REP(i, 0, n) typedef long long ll; typedef pair<ll, ll> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<P> vp; typedef vector<ll> vl; int dx[4] = {0, -1, 0, 1}; int dy[4] = {1, 0, -1, 0}; int sign[2] = {1, -1}; template <class T> bool chmax(T &a, T b) { if(a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, T b) { if(a > b) { a = b; return 1; } return 0; } ll modpow(ll a, ll b, ll m) { if(b == 0) return 1; ll t = modpow(a, b / 2, m); if(b & 1) { return (t * t % m) * a % m; } else { return t * t % m; } } struct edge { int to; ll cost; edge(int t, ll c) { to = t, cost = c; } }; typedef vector<vector<edge>> graph; using mint = modint998244353; vector<ll> dijkstra(vector<vector<edge>> &g, int start, int n) { priority_queue<P, vector<P>, greater<P>> que; vector<ll> dist(n, INF_LL); dist[start] = 0; que.push(P(0, start)); while(!que.empty()) { P p = que.top(); que.pop(); int v = p.second; if(dist[v] < p.first) continue; rep(i, (int)g[v].size()) { edge e = g[v][i]; if(dist[e.to] > dist[v] + e.cost) { dist[e.to] = dist[v] + e.cost; que.push(P(dist[e.to], e.to)); } } } return dist; } int main(){ cin.tie(0); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(16); int n, m, k; cin >> n >> m >> k; vector<pair<pair<int, int>, int>> e(m); rep(i, m){ cin >> e[i].first.first >> e[i].first.second >> e[i].second; } sort(all(e), [](auto &x, auto &y){return x.second < y.second;}); int l = -1, r = 200001; while(r - l > 1){ int md = (l + r) / 2; int idx = 0; graph g(n); while(idx < m and e[idx].second <= md){ g[e[idx].first.first - 1].push_back({e[idx].first.second - 1, 0}); g[e[idx].first.second - 1].push_back({e[idx].first.first - 1, 0}); idx++; } REP(i, idx, m){ g[e[i].first.first - 1].push_back({e[i].first.second - 1, 1}); g[e[i].first.second - 1].push_back({e[i].first.first - 1, 1}); } if((dijkstra(g, 0, n))[n - 1] <= k - 1){ r = md; }else{ l = md; } } cout << r << endl; }