結果

問題 No.1473 おでぶなおばけさん
ユーザー NoaSaberNoaSaber
提出日時 2021-04-09 23:09:44
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 761 bytes
コンパイル時間 423 ms
コンパイル使用メモリ 86,656 KB
実行使用メモリ 122,896 KB
最終ジャッジ日時 2023-09-07 12:54:27
合計ジャッジ時間 18,594 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,236 KB
testcase_01 AC 77 ms
70,988 KB
testcase_02 TLE -
testcase_03 WA -
testcase_04 AC 786 ms
89,756 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 577 ms
96,188 KB
testcase_08 WA -
testcase_09 AC 571 ms
96,384 KB
testcase_10 AC 270 ms
88,396 KB
testcase_11 WA -
testcase_12 AC 278 ms
88,924 KB
testcase_13 AC 169 ms
82,128 KB
testcase_14 AC 154 ms
81,084 KB
testcase_15 AC 192 ms
84,680 KB
testcase_16 AC 229 ms
85,692 KB
testcase_17 AC 122 ms
77,880 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
edge=[[] for i in range(n)]
for i in range(m):
    s,t,d=map(int,input().split())
    s-=1;t-=1
    edge[s].append((t,d*-1))
    edge[t].append((s,d*-1))
from heapq import heappop,heappush
def dijkstra(s,n,edge):
    inf=float("inf")
    ans=[inf]*n
    ans[s]=0
    root=[0]*n
    open=[[-inf,s]]
    while open:
        cost,node=heappop(open)
        if ans[node]<cost:
            continue
        for next,e_cost in edge[node]:
            if max(cost,e_cost)<ans[next] or (max(cost,e_cost)==ans[next] and root[next]>root[node]+1):
                ans[next]=max(cost,e_cost)
                root[next]=root[node]+1
                heappush(open,[max(cost,e_cost),next])
    return ans[-1]*-1,root[-1]
print(*dijkstra(0,n,edge))
0