結果

問題 No.1473 おでぶなおばけさん
ユーザー lloyzlloyz
提出日時 2022-08-11 22:27:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 900 ms / 2,000 ms
コード長 1,103 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 82,588 KB
実行使用メモリ 113,500 KB
最終ジャッジ日時 2024-09-22 05:21:23
合計ジャッジ時間 15,019 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,980 KB
testcase_01 AC 42 ms
54,556 KB
testcase_02 AC 621 ms
105,508 KB
testcase_03 AC 341 ms
100,408 KB
testcase_04 AC 344 ms
93,444 KB
testcase_05 AC 175 ms
80,516 KB
testcase_06 AC 513 ms
101,160 KB
testcase_07 AC 552 ms
105,088 KB
testcase_08 AC 900 ms
102,624 KB
testcase_09 AC 479 ms
108,156 KB
testcase_10 AC 139 ms
83,572 KB
testcase_11 AC 163 ms
83,524 KB
testcase_12 AC 134 ms
83,608 KB
testcase_13 AC 110 ms
80,144 KB
testcase_14 AC 93 ms
79,816 KB
testcase_15 AC 133 ms
83,244 KB
testcase_16 AC 129 ms
82,700 KB
testcase_17 AC 68 ms
73,840 KB
testcase_18 AC 79 ms
77,532 KB
testcase_19 AC 168 ms
84,400 KB
testcase_20 AC 315 ms
98,200 KB
testcase_21 AC 326 ms
93,012 KB
testcase_22 AC 208 ms
106,132 KB
testcase_23 AC 179 ms
103,708 KB
testcase_24 AC 177 ms
100,020 KB
testcase_25 AC 671 ms
98,912 KB
testcase_26 AC 302 ms
101,816 KB
testcase_27 AC 185 ms
81,964 KB
testcase_28 AC 455 ms
113,500 KB
testcase_29 AC 342 ms
94,568 KB
testcase_30 AC 486 ms
97,244 KB
testcase_31 AC 427 ms
109,244 KB
testcase_32 AC 376 ms
102,588 KB
testcase_33 AC 265 ms
95,636 KB
testcase_34 AC 148 ms
87,200 KB
testcase_35 AC 170 ms
88,364 KB
testcase_36 AC 386 ms
91,208 KB
testcase_37 AC 252 ms
103,404 KB
testcase_38 AC 87 ms
78,344 KB
testcase_39 AC 125 ms
82,752 KB
testcase_40 AC 128 ms
83,312 KB
testcase_41 AC 124 ms
86,812 KB
testcase_42 AC 124 ms
86,680 KB
testcase_43 AC 187 ms
96,644 KB
testcase_44 AC 186 ms
96,888 KB
testcase_45 AC 185 ms
97,148 KB
testcase_46 AC 259 ms
96,236 KB
testcase_47 AC 346 ms
101,296 KB
testcase_48 AC 342 ms
98,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import sys
input = sys.stdin.readline
INF = 1 << 30

n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
    s, t, d = map(int, input().split())
    s -= 1
    t -= 1
    edge[s].append((t, d))
    edge[t].append((s, d))

left, right = 1, 10**9 + 10
while right - left > 1:
    mid = (left + right) // 2
    Que = deque([0])
    C = [INF] * n
    C[0] = 0
    while Que:
        cp = Que.popleft()
        if cp == n - 1:
            break
        cnt = C[cp]
        for np, w in edge[cp]:
            if w < mid:
                continue
            if cnt + 1 >= C[np]:
                continue
            C[np] = cnt + 1
            Que.append(np)
    if C[n - 1] < INF:
        left = mid
    else:
        right = mid

Que = deque([0])
C = [INF] * n
C[0] = 0
while Que:
    cp = Que.popleft()
    if cp == n - 1:
        print(left, C[cp])
        break
    cnt = C[cp]
    for np, w in edge[cp]:
        if w < left:
            continue
        if cnt + 1 >= C[np]:
            continue
        C[np] = cnt + 1
        Que.append(np)
0