結果

問題 No.1473 おでぶなおばけさん
ユーザー lloyzlloyz
提出日時 2022-08-11 22:19:39
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,385 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 81,752 KB
実行使用メモリ 856,664 KB
最終ジャッジ日時 2023-10-22 03:54:19
合計ジャッジ時間 19,748 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,656 KB
testcase_01 AC 41 ms
55,656 KB
testcase_02 AC 758 ms
100,644 KB
testcase_03 AC 388 ms
98,036 KB
testcase_04 AC 426 ms
89,536 KB
testcase_05 AC 180 ms
79,596 KB
testcase_06 AC 659 ms
95,696 KB
testcase_07 AC 643 ms
101,852 KB
testcase_08 AC 1,044 ms
101,996 KB
testcase_09 AC 526 ms
103,348 KB
testcase_10 AC 162 ms
83,204 KB
testcase_11 AC 266 ms
83,132 KB
testcase_12 AC 137 ms
83,232 KB
testcase_13 AC 130 ms
81,600 KB
testcase_14 AC 98 ms
79,532 KB
testcase_15 AC 187 ms
83,628 KB
testcase_16 AC 126 ms
82,448 KB
testcase_17 AC 66 ms
72,800 KB
testcase_18 AC 82 ms
76,916 KB
testcase_19 AC 175 ms
83,896 KB
testcase_20 AC 313 ms
96,740 KB
testcase_21 AC 454 ms
91,856 KB
testcase_22 AC 229 ms
105,808 KB
testcase_23 AC 205 ms
105,240 KB
testcase_24 AC 212 ms
101,180 KB
testcase_25 AC 818 ms
99,488 KB
testcase_26 AC 328 ms
98,472 KB
testcase_27 AC 234 ms
83,288 KB
testcase_28 AC 512 ms
102,764 KB
testcase_29 AC 451 ms
94,844 KB
testcase_30 AC 650 ms
98,268 KB
testcase_31 AC 485 ms
107,784 KB
testcase_32 AC 435 ms
101,040 KB
testcase_33 AC 284 ms
95,144 KB
testcase_34 AC 149 ms
86,708 KB
testcase_35 AC 188 ms
87,632 KB
testcase_36 AC 549 ms
90,620 KB
testcase_37 AC 259 ms
99,592 KB
testcase_38 AC 88 ms
77,884 KB
testcase_39 AC 123 ms
82,408 KB
testcase_40 AC 123 ms
82,412 KB
testcase_41 AC 160 ms
88,344 KB
testcase_42 AC 124 ms
88,340 KB
testcase_43 MLE -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def main():
    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
        flag = False
        Que = deque([0])
        C = [INF for _ in range(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 for _ in range(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)

if __name__ == '__main__':
    main()
0