結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
55,644 KB
testcase_01 AC 42 ms
55,644 KB
testcase_02 AC 770 ms
107,504 KB
testcase_03 AC 365 ms
102,752 KB
testcase_04 AC 371 ms
93,284 KB
testcase_05 AC 209 ms
81,260 KB
testcase_06 AC 792 ms
99,788 KB
testcase_07 AC 713 ms
107,256 KB
testcase_08 AC 1,068 ms
106,400 KB
testcase_09 AC 568 ms
108,100 KB
testcase_10 AC 191 ms
83,720 KB
testcase_11 AC 327 ms
86,152 KB
testcase_12 AC 184 ms
83,748 KB
testcase_13 AC 161 ms
82,376 KB
testcase_14 AC 120 ms
78,664 KB
testcase_15 AC 228 ms
84,724 KB
testcase_16 AC 169 ms
82,664 KB
testcase_17 AC 90 ms
77,012 KB
testcase_18 AC 98 ms
77,032 KB
testcase_19 AC 233 ms
84,980 KB
testcase_20 AC 404 ms
101,656 KB
testcase_21 AC 599 ms
92,704 KB
testcase_22 AC 315 ms
109,780 KB
testcase_23 AC 234 ms
109,480 KB
testcase_24 AC 243 ms
104,468 KB
testcase_25 AC 733 ms
104,620 KB
testcase_26 AC 337 ms
100,960 KB
testcase_27 AC 251 ms
83,144 KB
testcase_28 AC 500 ms
109,028 KB
testcase_29 AC 436 ms
95,944 KB
testcase_30 AC 629 ms
102,452 KB
testcase_31 AC 509 ms
113,612 KB
testcase_32 AC 424 ms
104,800 KB
testcase_33 AC 296 ms
98,204 KB
testcase_34 AC 173 ms
91,380 KB
testcase_35 AC 202 ms
86,156 KB
testcase_36 AC 564 ms
93,520 KB
testcase_37 AC 280 ms
102,516 KB
testcase_38 AC 99 ms
77,412 KB
testcase_39 AC 149 ms
82,684 KB
testcase_40 AC 155 ms
82,672 KB
testcase_41 AC 183 ms
87,468 KB
testcase_42 AC 150 ms
87,320 KB
testcase_43 MLE -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque

def main():
    n, m = map(int, input().split())
    edge = defaultdict(list)
    for _ in range(m):
        s, t, d = map(int, input().split())
        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([1])
        C = [10**9 for _ in range(n + 1)]
        C[1] = 0
        while Que:
            cp = Que.popleft()
            if cp == n:
                flag = True
                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 flag:
            left = mid
        else:
            right = mid

    Que = deque([1])
    C = [10**9 for _ in range(n + 1)]
    C[1] = 0
    while Que:
        cp = Que.popleft()
        if cp == n:
            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