結果

問題 No.1473 おでぶなおばけさん
ユーザー mkawa2mkawa2
提出日時 2021-04-09 21:59:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,045 ms / 2,000 ms
コード長 1,452 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 11,040 KB
実行使用メモリ 45,660 KB
最終ジャッジ日時 2023-09-07 11:15:07
合計ジャッジ時間 27,368 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,172 KB
testcase_01 AC 17 ms
8,172 KB
testcase_02 AC 901 ms
43,400 KB
testcase_03 AC 439 ms
37,616 KB
testcase_04 AC 396 ms
27,272 KB
testcase_05 AC 145 ms
15,516 KB
testcase_06 AC 628 ms
41,392 KB
testcase_07 AC 684 ms
44,408 KB
testcase_08 AC 966 ms
45,592 KB
testcase_09 AC 708 ms
43,856 KB
testcase_10 AC 421 ms
29,896 KB
testcase_11 AC 435 ms
28,460 KB
testcase_12 AC 351 ms
30,348 KB
testcase_13 AC 191 ms
20,500 KB
testcase_14 AC 188 ms
17,000 KB
testcase_15 AC 353 ms
25,256 KB
testcase_16 AC 290 ms
28,596 KB
testcase_17 AC 34 ms
9,768 KB
testcase_18 AC 52 ms
10,472 KB
testcase_19 AC 406 ms
30,036 KB
testcase_20 AC 471 ms
34,556 KB
testcase_21 AC 730 ms
37,856 KB
testcase_22 AC 876 ms
35,432 KB
testcase_23 AC 710 ms
31,332 KB
testcase_24 AC 750 ms
30,880 KB
testcase_25 AC 907 ms
38,132 KB
testcase_26 AC 797 ms
39,400 KB
testcase_27 AC 301 ms
20,220 KB
testcase_28 AC 621 ms
42,560 KB
testcase_29 AC 431 ms
34,940 KB
testcase_30 AC 522 ms
39,604 KB
testcase_31 AC 1,045 ms
43,472 KB
testcase_32 AC 623 ms
42,328 KB
testcase_33 AC 641 ms
35,736 KB
testcase_34 AC 304 ms
22,724 KB
testcase_35 AC 352 ms
25,268 KB
testcase_36 AC 644 ms
30,920 KB
testcase_37 AC 602 ms
32,144 KB
testcase_38 AC 107 ms
13,528 KB
testcase_39 AC 327 ms
28,952 KB
testcase_40 AC 285 ms
28,800 KB
testcase_41 AC 265 ms
25,752 KB
testcase_42 AC 272 ms
25,716 KB
testcase_43 AC 674 ms
45,604 KB
testcase_44 AC 673 ms
45,660 KB
testcase_45 AC 680 ms
45,580 KB
testcase_46 AC 549 ms
35,640 KB
testcase_47 AC 644 ms
41,252 KB
testcase_48 AC 600 ms
38,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def FI(): return float(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
dij = [(0, 1), (1, 0), (1, 1), (1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

from heapq import *

n,m=LI()
to=[[] for _ in range(n)]
for _ in range(m):
    u,v,d=LI()
    u,v=u-1,v-1
    to[u].append((v,d))
    to[v].append((u,d))

ww=[0]*n
ww[0]=inf
ee=[inf]*n
ee[0]=0

hp=[(-inf,0)]
while hp:
    w,u=heappop(hp)
    w=-w
    if w<ww[u]:continue
    if u==n-1:break
    for v,lim in to[u]:
        nw=min(lim,w)
        if ww[v]>=nw:continue
        ww[v]=nw
        heappush(hp,(-nw,v))

hp=[(0,0)]
while hp:
    e,u=heappop(hp)
    if e>ee[u]:continue
    if u==n-1:break
    for v,lim in to[u]:
        if lim<ww[-1]:continue
        if ee[v]<=e+1:continue
        ee[v]=e+1
        heappush(hp,(e+1,v))

print(ww[-1],ee[-1])
0