結果
| 問題 |
No.1607 Kth Maximum Card
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-09 18:28:34 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 787 bytes |
| コンパイル時間 | 225 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 76,040 KB |
| 最終ジャッジ日時 | 2024-07-16 16:25:58 |
| 合計ジャッジ時間 | 7,107 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 2 -- * 25 |
ソースコード
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)