結果

問題 No.1473 おでぶなおばけさん
ユーザー ronpooronpoo
提出日時 2023-10-31 13:49:37
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,044 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 125,856 KB
最終ジャッジ日時 2023-10-31 13:49:55
合計ジャッジ時間 17,136 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
55,660 KB
testcase_01 RE -
testcase_02 AC 430 ms
119,496 KB
testcase_03 AC 302 ms
117,208 KB
testcase_04 AC 233 ms
100,832 KB
testcase_05 AC 143 ms
82,636 KB
testcase_06 AC 438 ms
111,936 KB
testcase_07 AC 388 ms
124,780 KB
testcase_08 AC 531 ms
125,308 KB
testcase_09 AC 338 ms
124,768 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 315 ms
106,964 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 298 ms
125,856 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 342 ms
121,712 KB
testcase_32 AC 427 ms
112,584 KB
testcase_33 AC 258 ms
110,880 KB
testcase_34 AC 140 ms
94,136 KB
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 AC 207 ms
110,848 KB
testcase_44 AC 204 ms
110,848 KB
testcase_45 AC 217 ms
110,848 KB
testcase_46 TLE -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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')] * (n+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])
0