結果
問題 | No.1607 Kth Maximum Card |
ユーザー | LyricalMaestro |
提出日時 | 2024-09-03 02:28:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,232 ms / 3,500 ms |
コード長 | 1,357 bytes |
コンパイル時間 | 412 ms |
コンパイル使用メモリ | 82,604 KB |
実行使用メモリ | 172,624 KB |
最終ジャッジ日時 | 2024-09-03 02:28:58 |
合計ジャッジ時間 | 26,870 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
54,376 KB |
testcase_01 | AC | 42 ms
54,440 KB |
testcase_02 | AC | 42 ms
55,620 KB |
testcase_03 | AC | 42 ms
55,240 KB |
testcase_04 | AC | 42 ms
54,852 KB |
testcase_05 | AC | 42 ms
54,800 KB |
testcase_06 | AC | 42 ms
54,488 KB |
testcase_07 | AC | 43 ms
55,180 KB |
testcase_08 | AC | 1,755 ms
157,392 KB |
testcase_09 | AC | 1,824 ms
148,724 KB |
testcase_10 | AC | 2,232 ms
172,624 KB |
testcase_11 | AC | 330 ms
93,388 KB |
testcase_12 | AC | 1,659 ms
138,504 KB |
testcase_13 | AC | 270 ms
87,520 KB |
testcase_14 | AC | 279 ms
91,764 KB |
testcase_15 | AC | 1,270 ms
140,588 KB |
testcase_16 | AC | 242 ms
89,296 KB |
testcase_17 | AC | 134 ms
80,056 KB |
testcase_18 | AC | 636 ms
116,660 KB |
testcase_19 | AC | 415 ms
101,788 KB |
testcase_20 | AC | 585 ms
107,780 KB |
testcase_21 | AC | 646 ms
110,128 KB |
testcase_22 | AC | 1,666 ms
154,608 KB |
testcase_23 | AC | 1,721 ms
154,788 KB |
testcase_24 | AC | 581 ms
99,568 KB |
testcase_25 | AC | 347 ms
91,748 KB |
testcase_26 | AC | 369 ms
93,608 KB |
testcase_27 | AC | 477 ms
99,676 KB |
testcase_28 | AC | 445 ms
95,256 KB |
testcase_29 | AC | 1,205 ms
120,220 KB |
testcase_30 | AC | 2,074 ms
155,584 KB |
testcase_31 | AC | 1,078 ms
117,072 KB |
testcase_32 | AC | 337 ms
117,568 KB |
testcase_33 | AC | 480 ms
117,444 KB |
testcase_34 | AC | 464 ms
121,408 KB |
testcase_35 | AC | 507 ms
121,276 KB |
ソースコード
## https://yukicoder.me/problems/no/1607 from collections import deque MAX_INT = 10 ** 18 def solve(N, next_nodes, K, value): # 01BFSで問題を解く dists = [MAX_INT ] * N dists[0] = 0 queue = deque() queue.append(0) while len(queue) > 0: v = queue.popleft() for w, cost in next_nodes[v]: if cost > value: if dists[w] > dists[v] + 1: dists[w] = dists[v] + 1 queue.append(w) else: if dists[w] > dists[v]: dists[w] = dists[v] queue.appendleft(w) return dists[N - 1] < K def main(): N, M, K = map(int, input().split()) edges = [] max_c = 0 for _ in range(M): u, v, c = map(int, input().split()) edges.append((u - 1, v - 1, c)) max_c = max(c, max_c) next_nodes = [[] for _ in range(N)] for u, v, c in edges: next_nodes[u].append((v, c)) next_nodes[v].append((u, c)) low = 0 high = max_c while high - low > 1: mid = (high + low) // 2 if solve(N, next_nodes, K, mid): high = mid else: low = mid if solve(N, next_nodes, K, low): print(low) else: print(high) if __name__ == "__main__": main()