結果

問題 No.1607 Kth Maximum Card
ユーザー DrDrpilotDrDrpilot
提出日時 2022-05-09 18:28:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,014 ms / 3,500 ms
コード長 787 bytes
コンパイル時間 1,702 ms
コンパイル使用メモリ 86,644 KB
実行使用メモリ 154,728 KB
最終ジャッジ日時 2023-09-23 16:34:13
合計ジャッジ時間 24,924 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,436 KB
testcase_01 AC 90 ms
71,180 KB
testcase_02 AC 89 ms
71,432 KB
testcase_03 AC 90 ms
71,560 KB
testcase_04 AC 90 ms
71,604 KB
testcase_05 AC 92 ms
71,448 KB
testcase_06 AC 90 ms
71,436 KB
testcase_07 AC 92 ms
71,524 KB
testcase_08 AC 1,560 ms
143,280 KB
testcase_09 AC 871 ms
123,044 KB
testcase_10 AC 2,014 ms
154,728 KB
testcase_11 AC 256 ms
94,828 KB
testcase_12 AC 1,194 ms
129,516 KB
testcase_13 AC 317 ms
87,472 KB
testcase_14 AC 340 ms
89,352 KB
testcase_15 AC 998 ms
122,052 KB
testcase_16 AC 265 ms
87,456 KB
testcase_17 AC 223 ms
80,328 KB
testcase_18 AC 714 ms
105,636 KB
testcase_19 AC 427 ms
94,468 KB
testcase_20 AC 618 ms
98,076 KB
testcase_21 AC 704 ms
102,484 KB
testcase_22 AC 1,032 ms
140,224 KB
testcase_23 AC 1,016 ms
140,220 KB
testcase_24 AC 522 ms
94,908 KB
testcase_25 AC 375 ms
89,500 KB
testcase_26 AC 438 ms
91,884 KB
testcase_27 AC 609 ms
96,332 KB
testcase_28 AC 481 ms
93,260 KB
testcase_29 AC 1,071 ms
114,844 KB
testcase_30 AC 1,940 ms
139,580 KB
testcase_31 AC 1,124 ms
112,576 KB
testcase_32 AC 348 ms
103,000 KB
testcase_33 AC 332 ms
102,904 KB
testcase_34 AC 373 ms
102,792 KB
testcase_35 AC 386 ms
102,596 KB
権限があれば一括ダウンロードができます

ソースコード

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