結果

問題 No.1473 おでぶなおばけさん
ユーザー terasaterasa
提出日時 2022-06-02 22:54:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 861 ms / 2,000 ms
コード長 1,431 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 81,760 KB
実行使用メモリ 109,992 KB
最終ジャッジ日時 2023-10-21 01:21:15
合計ジャッジ時間 13,136 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,740 KB
testcase_01 AC 40 ms
55,740 KB
testcase_02 AC 442 ms
102,752 KB
testcase_03 AC 265 ms
102,132 KB
testcase_04 AC 269 ms
92,428 KB
testcase_05 AC 161 ms
80,316 KB
testcase_06 AC 477 ms
99,384 KB
testcase_07 AC 458 ms
102,848 KB
testcase_08 AC 861 ms
102,272 KB
testcase_09 AC 442 ms
104,008 KB
testcase_10 AC 132 ms
83,284 KB
testcase_11 AC 154 ms
83,256 KB
testcase_12 AC 144 ms
83,396 KB
testcase_13 AC 105 ms
79,904 KB
testcase_14 AC 97 ms
79,612 KB
testcase_15 AC 128 ms
83,016 KB
testcase_16 AC 129 ms
82,620 KB
testcase_17 AC 66 ms
73,588 KB
testcase_18 AC 75 ms
77,228 KB
testcase_19 AC 145 ms
84,076 KB
testcase_20 AC 260 ms
98,200 KB
testcase_21 AC 272 ms
92,332 KB
testcase_22 AC 183 ms
105,868 KB
testcase_23 AC 152 ms
103,340 KB
testcase_24 AC 156 ms
101,080 KB
testcase_25 AC 324 ms
104,360 KB
testcase_26 AC 209 ms
102,892 KB
testcase_27 AC 133 ms
81,220 KB
testcase_28 AC 342 ms
109,992 KB
testcase_29 AC 308 ms
93,488 KB
testcase_30 AC 406 ms
96,428 KB
testcase_31 AC 327 ms
109,256 KB
testcase_32 AC 354 ms
100,568 KB
testcase_33 AC 221 ms
95,288 KB
testcase_34 AC 131 ms
86,912 KB
testcase_35 AC 176 ms
87,392 KB
testcase_36 AC 307 ms
90,584 KB
testcase_37 AC 185 ms
100,188 KB
testcase_38 AC 78 ms
78,092 KB
testcase_39 AC 117 ms
82,608 KB
testcase_40 AC 119 ms
82,588 KB
testcase_41 AC 109 ms
86,000 KB
testcase_42 AC 110 ms
86,000 KB
testcase_43 AC 150 ms
95,676 KB
testcase_44 AC 155 ms
95,672 KB
testcase_45 AC 155 ms
95,676 KB
testcase_46 AC 194 ms
95,668 KB
testcase_47 AC 294 ms
100,764 KB
testcase_48 AC 258 ms
100,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


def index_lt(a, x):
    'return largest index s.t. A[i] < x or -1 if it does not exist'
    return bisect.bisect_left(a, x) - 1


def index_le(a, x):
    'return largest index s.t. A[i] <= x or -1 if it does not exist'
    return bisect.bisect_right(a, x) - 1


def index_gt(a, x):
    'return smallest index s.t. A[i] > x or len(a) if it does not exist'
    return bisect.bisect_right(a, x)


def index_ge(a, x):
    'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
    return bisect.bisect_left(a, x)


N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    s, t, d = map(int, input().split())
    s -= 1
    t -= 1
    E[s].append((d, t))
    E[t].append((d, s))

INF = 1 << 30
l = -1
r = INF
while r - l > 1:
    w = (l + r) // 2

    dq = deque([0])
    C = [INF] * N
    C[0] = 0
    while len(dq) > 0:
        v = dq.popleft()
        if v == N - 1:
            break
        for d, dest in E[v]:
            if w > d:
                continue
            if C[dest] > C[v] + 1:
                C[dest] = C[v] + 1
                dq.append(dest)
    if C[N - 1] < INF:
        l = w
        ans = C[N - 1]
    else:
        r = w
print(l, ans)
0