結果
問題 |
No.1473 おでぶなおばけさん
|
ユーザー |
|
提出日時 | 2023-10-31 13:52:09 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,044 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 66,644 KB |
最終ジャッジ日時 | 2024-09-25 17:37:46 |
合計ジャッジ時間 | 37,982 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 44 TLE * 1 -- * 2 |
ソースコード
import sys from collections import deque input = sys.stdin.readline n, m = map(int, input().split()) std = [list(map(int, input().split())) for _ in range(m)] G = [[] for _ in range(n)] D = [] W = [float('inf')] * (m+2) for i in range(m): s, t, d = std[i] s -= 1 t -= 1 G[s].append((t, d)) G[t].append((s, d)) D.append(d) def bfs(cost): dist = [float('inf')] * n dist[0] = 0 q = deque([0]) while q: now = q.popleft() for nxt, d in G[now]: if dist[nxt] < dist[now] + 1: continue if d < cost: continue dist[nxt] = dist[now] + 1 if nxt == n-1: return dist[nxt] q.append(nxt) return float('inf') D.append(0) D.append(float('inf')) D.sort() ok = 0 ng = len(D) while ng - ok > 1: mid = (ng + ok) // 2 W[mid] = bfs(D[mid]) if W[mid] != float('inf'): ok = mid else: ng = mid print(D[ok], W[ok])