結果
| 問題 |
No.1473 おでぶなおばけさん
|
| コンテスト | |
| ユーザー |
310icecrystal
|
| 提出日時 | 2023-07-06 05:02:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,219 ms / 2,000 ms |
| コード長 | 725 bytes |
| コンパイル時間 | 367 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 147,456 KB |
| 最終ジャッジ日時 | 2024-07-20 00:06:08 |
| 合計ジャッジ時間 | 25,404 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 47 |
ソースコード
n,m = map(int,input().split())
graph = [set() for _ in range(n+1)]
for _ in range(m):
s,t,d = map(int,input().split())
graph[s].add((t,d))
graph[t].add((s,d))
from collections import deque
def bfs(G,start,w):
Deq = deque()
dist = [-1] * (n + 1)
Deq.append(start)
dist[start] = 0
while Deq :
pos = Deq.popleft()
for nex,d in G[pos] :
if dist[nex] == -1 and w <= d:
dist[nex] = dist[pos] + 1
Deq.append(nex)
return dist
OK = 0
NG = 10**18
while NG - OK >= 2:
MID = (OK+NG)//2
dist_MID = bfs(graph,1,MID)
if dist_MID[n] != -1:
OK = MID
else:
NG = MID
dist_OK = bfs(graph,1,OK)
print(OK,dist_OK[n])
310icecrystal