結果

問題 No.1607 Kth Maximum Card
ユーザー convexineqconvexineq
提出日時 2021-07-16 22:23:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,254 ms / 3,500 ms
コード長 859 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 161,944 KB
最終ジャッジ日時 2023-09-20 14:37:33
合計ジャッジ時間 25,588 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,644 KB
testcase_01 AC 92 ms
71,616 KB
testcase_02 AC 92 ms
71,620 KB
testcase_03 AC 91 ms
71,784 KB
testcase_04 AC 91 ms
71,632 KB
testcase_05 AC 93 ms
71,616 KB
testcase_06 AC 92 ms
71,580 KB
testcase_07 AC 92 ms
71,488 KB
testcase_08 AC 1,688 ms
152,060 KB
testcase_09 AC 995 ms
124,320 KB
testcase_10 AC 2,168 ms
161,944 KB
testcase_11 AC 239 ms
89,524 KB
testcase_12 AC 1,426 ms
144,248 KB
testcase_13 AC 296 ms
84,624 KB
testcase_14 AC 336 ms
87,488 KB
testcase_15 AC 1,170 ms
124,008 KB
testcase_16 AC 277 ms
85,324 KB
testcase_17 AC 195 ms
80,024 KB
testcase_18 AC 727 ms
105,124 KB
testcase_19 AC 461 ms
93,392 KB
testcase_20 AC 632 ms
101,088 KB
testcase_21 AC 677 ms
102,744 KB
testcase_22 AC 1,120 ms
138,336 KB
testcase_23 AC 1,209 ms
138,296 KB
testcase_24 AC 630 ms
95,432 KB
testcase_25 AC 389 ms
87,764 KB
testcase_26 AC 491 ms
90,216 KB
testcase_27 AC 692 ms
95,140 KB
testcase_28 AC 554 ms
91,580 KB
testcase_29 AC 1,212 ms
113,808 KB
testcase_30 AC 2,254 ms
136,876 KB
testcase_31 AC 1,125 ms
112,988 KB
testcase_32 AC 278 ms
100,000 KB
testcase_33 AC 265 ms
99,996 KB
testcase_34 AC 328 ms
100,112 KB
testcase_35 AC 282 ms
99,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def check(mid): # mid より大きい辺を使う最小回数
    d = [1000000]*n
    d[0] = 0
    q = deque()
    q.append((0,0))
    while q:
        v,dist = q.popleft()
        if v==n-1:
            return d[v]
        if d[v] > dist: continue
        for u,c in g[v]:
            cost = int(c > mid)
            nd = d[v] + cost
            if nd < d[u]:
                d[u] = nd
                if cost: q.append((u,nd))
                else: q.appendleft((u,nd))
    return 1000000

import sys
readline = sys.stdin.readline
n,m,k = map(int,readline().split())
g = [[] for _ in range(n)]
for _ in range(m):
    u,v,c = map(int,readline().split())
    g[u-1].append((v-1,c))
    g[v-1].append((u-1,c))
ng = -1
ok = 2*10**5+1
while ok-ng>1:
    mid = (ok+ng)//2
    if check(mid) < k: ok = mid
    else: ng = mid
print(ok)
0