結果

問題 No.1473 おでぶなおばけさん
ユーザー DrDrpilot
提出日時 2022-05-08 16:21:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 697 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 53,180 KB
最終ジャッジ日時 2024-07-08 04:43:38
合計ジャッジ時間 50,621 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 46 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n,m=map(int,input().split())
g=[[] for _ in range(n)]
W=[]
for _ in range(m):
    s,t,d=map(int,input().split())
    s-=1;t-=1
    W.append(d)
    g[s].append([t,d])
    g[t].append([s,d])
def bfs(w):
    dst=[-1]*n 
    dst[0]=0
    q=deque()
    q.append(0)
    while q:
        now=q.popleft()
        for to,limit in g[now]:
            if limit<w:
                continue
            if dst[to]!=-1:
                continue
            dst[to]=dst[now]+1
            q.append(to)
    return dst[-1]
W=list(set(W))
W.sort()
ng=len(W)
ok=-1
while ng-ok>1:
    mid=(ok+ng)//2
    if bfs(W[mid])!=-1:
        ok=mid
    else:
        ng=mid
print(W[ok],bfs(W[ok]))
0