結果
| 問題 |
No.1607 Kth Maximum Card
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-09 18:28:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,747 ms / 3,500 ms |
| コード長 | 787 bytes |
| コンパイル時間 | 882 ms |
| コンパイル使用メモリ | 82,472 KB |
| 実行使用メモリ | 154,152 KB |
| 最終ジャッジ日時 | 2024-07-16 16:26:36 |
| 合計ジャッジ時間 | 20,486 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
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)