結果

問題 No.1473 おでぶなおばけさん
ユーザー kohei2019kohei2019
提出日時 2022-05-21 19:25:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,371 ms / 2,000 ms
コード長 1,205 bytes
コンパイル時間 417 ms
コンパイル使用メモリ 81,912 KB
実行使用メモリ 207,796 KB
最終ジャッジ日時 2023-10-20 16:34:36
合計ジャッジ時間 29,484 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,648 KB
testcase_01 AC 41 ms
55,648 KB
testcase_02 AC 1,122 ms
165,576 KB
testcase_03 AC 579 ms
155,596 KB
testcase_04 AC 641 ms
128,272 KB
testcase_05 AC 246 ms
81,088 KB
testcase_06 AC 1,020 ms
143,216 KB
testcase_07 AC 939 ms
181,300 KB
testcase_08 AC 1,371 ms
181,700 KB
testcase_09 AC 708 ms
181,700 KB
testcase_10 AC 265 ms
83,768 KB
testcase_11 AC 287 ms
83,676 KB
testcase_12 AC 224 ms
83,796 KB
testcase_13 AC 166 ms
80,912 KB
testcase_14 AC 159 ms
78,732 KB
testcase_15 AC 229 ms
83,544 KB
testcase_16 AC 181 ms
82,704 KB
testcase_17 AC 87 ms
77,044 KB
testcase_18 AC 100 ms
77,068 KB
testcase_19 AC 303 ms
84,916 KB
testcase_20 AC 459 ms
163,756 KB
testcase_21 AC 599 ms
120,868 KB
testcase_22 AC 465 ms
193,100 KB
testcase_23 AC 433 ms
190,204 KB
testcase_24 AC 398 ms
171,628 KB
testcase_25 AC 958 ms
143,172 KB
testcase_26 AC 1,008 ms
134,164 KB
testcase_27 AC 251 ms
82,056 KB
testcase_28 AC 1,158 ms
168,224 KB
testcase_29 AC 706 ms
124,012 KB
testcase_30 AC 819 ms
122,112 KB
testcase_31 AC 782 ms
207,796 KB
testcase_32 AC 717 ms
171,220 KB
testcase_33 AC 553 ms
153,680 KB
testcase_34 AC 295 ms
123,056 KB
testcase_35 AC 294 ms
106,472 KB
testcase_36 AC 506 ms
106,308 KB
testcase_37 AC 752 ms
138,152 KB
testcase_38 AC 156 ms
78,852 KB
testcase_39 AC 195 ms
82,748 KB
testcase_40 AC 179 ms
82,720 KB
testcase_41 AC 230 ms
87,300 KB
testcase_42 AC 232 ms
87,300 KB
testcase_43 AC 329 ms
142,388 KB
testcase_44 AC 327 ms
142,392 KB
testcase_45 AC 325 ms
142,392 KB
testcase_46 AC 441 ms
154,180 KB
testcase_47 AC 509 ms
166,944 KB
testcase_48 AC 588 ms
168,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
N,M = map(int,input().split())
lsg = [[] for i in range(N)]
for i in range(M):
    s,t,d = map(int,input().split())
    s -= 1
    t -= 1
    lsg[s].append((t,d))
    lsg[t].append((s,d))
INF = float('INF')
def is_ok(arg):
    d = collections.deque([0])
    used = [False]*(N)
    cost = [INF]*N
    cost[0] = 0
    while d:
        x = d.popleft()
        if used[x]:
            continue
        used[x] = True
        for y,c in lsg[x]:
            if used[y]:
                continue
            if (cost[y] > cost[x] + 1) and (arg <= c):
                cost[y] = cost[x] + 1
                d.append(y)
    return used[N-1]
 
def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
w = meguru_bisect(10**18+1,0)
d = collections.deque([0])
used = [False]*(N)
cost = [INF]*N
cost[0] = 0
while d:
    x = d.popleft()
    if used[x]:
        continue
    used[x] = True
    for y,c in lsg[x]:
        if used[y]:
            continue
        if (cost[y] > cost[x] + 1) and (w <= c):
            cost[y] = cost[x] + 1
            d.append(y)

print(w,cost[N-1])
0