結果
| 問題 |
No.1473 おでぶなおばけさん
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2021-04-10 00:45:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 816 ms / 2,000 ms |
| コード長 | 728 bytes |
| コンパイル時間 | 188 ms |
| コンパイル使用メモリ | 82,500 KB |
| 実行使用メモリ | 134,400 KB |
| 最終ジャッジ日時 | 2024-06-25 13:27:26 |
| 合計ジャッジ時間 | 15,483 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 47 |
ソースコード
import sys
input = sys.stdin.readline
from collections import deque
n,m=map(int,input().split())
E=[[] for i in range(n+1)]
for i in range(m):
s,t,d=map(int,input().split())
E[s].append((t,d))
E[t].append((s,d))
OK=1
NG=1<<60
while NG-OK>1:
mid=(OK+NG)//2
GO=[0]*(n+1)
GO[1]=1
Q=[1]
while Q:
x=Q.pop()
for to,d in E[x]:
if d>=mid and GO[to]==0:
GO[to]=1
Q.append(to)
if GO[n]==1:
OK=mid
else:
NG=mid
X=[-1]*(n+1)
X[1]=0
Q=deque([1])
while Q:
x=Q.popleft()
for to,d in E[x]:
if d>=OK and X[to]==-1:
X[to]=X[x]+1
Q.append(to)
print(OK,X[n])
titia