結果

問題 No.1473 おでぶなおばけさん
ユーザー ronpooronpoo
提出日時 2023-10-31 13:33:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 970 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 441,696 KB
最終ジャッジ日時 2023-10-31 13:33:44
合計ジャッジ時間 21,782 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
60,012 KB
testcase_01 AC 38 ms
55,664 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 161 ms
82,940 KB
testcase_06 WA -
testcase_07 AC 445 ms
124,496 KB
testcase_08 AC 495 ms
126,080 KB
testcase_09 AC 408 ms
126,080 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 467 ms
111,396 KB
testcase_23 AC 539 ms
106,240 KB
testcase_24 AC 450 ms
105,124 KB
testcase_25 AC 367 ms
110,208 KB
testcase_26 AC 290 ms
118,408 KB
testcase_27 AC 162 ms
88,056 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 443 ms
126,100 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 161 ms
92,340 KB
testcase_35 WA -
testcase_36 AC 431 ms
101,596 KB
testcase_37 AC 286 ms
110,760 KB
testcase_38 AC 106 ms
80,540 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 196 ms
106,964 KB
testcase_42 AC 201 ms
106,960 KB
testcase_43 AC 265 ms
111,964 KB
testcase_44 AC 247 ms
111,804 KB
testcase_45 AC 247 ms
111,952 KB
testcase_46 TLE -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

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')
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):
    global w
    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:
                w = min(w, dist[nxt])
                return True
            q.append(nxt)
    return False

D.append(0)
D.append(float('inf'))
D.sort()
ok = 0
ng = len(D)
while ng - ok > 1:
    mid = (ng + ok) // 2
    if bfs(D[mid]):
        ok = mid
    else:
        ng = mid
                
print(D[ok], w)
0