結果
問題 |
No.1607 Kth Maximum Card
|
ユーザー |
|
提出日時 | 2022-03-07 11:22:24 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 848 bytes |
コンパイル時間 | 410 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 146,852 KB |
最終ジャッジ日時 | 2024-07-22 04:50:04 |
合計ジャッジ時間 | 7,094 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 TLE * 2 |
ソースコード
N,M,K = map(int,input().split()) G = [[] for _ in range(N+1)] for _ in range(M): a,b,c = map(int,input().split()) G[a].append((b,c)) G[b].append((a,c)) import heapq inf = 10 ** 6 base = 23 mask = (1 << base) - 1 def calc(x): dist = [inf] * (N+1) dist[1] = 0 q = [1] while q: u = heapq.heappop(q) d,now = u >> base,u & mask if now == N:break if dist[now] < d: continue for v,c in G[now]: if c > x: c = 1 else: c = 0 if dist[v] > d + c: dist[v] = d + c heapq.heappush(q,(d+c) << base | v) return dist[N] < K start = -1 end = 2 * 10 ** 5 while end - start > 1: mid = (end + start) // 2 if calc(mid): end = mid else: start = mid print(end)