結果

問題 No.1607 Kth Maximum Card
ユーザー DrDrpilotDrDrpilot
提出日時 2022-05-09 18:28:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 787 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 73,752 KB
最終ジャッジ日時 2023-09-23 16:33:34
合計ジャッジ時間 15,904 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,688 KB
testcase_01 AC 18 ms
8,548 KB
testcase_02 AC 20 ms
8,468 KB
testcase_03 AC 20 ms
8,608 KB
testcase_04 AC 19 ms
8,488 KB
testcase_05 AC 18 ms
8,496 KB
testcase_06 AC 17 ms
8,524 KB
testcase_07 AC 18 ms
8,552 KB
testcase_08 TLE -
testcase_09 AC 2,519 ms
62,120 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,k=map(int,input().split())
from collections import deque
g=[[] for _ in range(n)]
for _ in range(m):
    a,b,c=map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
def bfs(x):
    dst=[float('inf')]*n
    dst[0]=0
    q=deque()
    q.append((0,0))
    while q:
        now,d=q.popleft()
        if now==n-1:break
        if dst[now]<d:continue
        for to,num in g[now]:
            if num>x:
                if dst[to]>d+1:
                    dst[to]=d+1
                    q.append((to,d+1))
            else:
                if dst[to]>d:
                    dst[to]=d
                    q.appendleft((to,d))
    return dst[n-1]
ok=2*10**5
ng=-1
while ok-ng>1:
    mid=(ok+ng)//2
    if bfs(mid)<k:
        ok=mid
    else:
        ng=mid
print(ok)
0