結果

問題 No.1473 おでぶなおばけさん
ユーザー NoaSaberNoaSaber
提出日時 2021-04-13 22:34:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 989 ms / 2,000 ms
コード長 1,005 bytes
コンパイル時間 418 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 103,900 KB
最終ジャッジ日時 2023-09-12 13:21:57
合計ジャッジ時間 25,287 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
71,172 KB
testcase_01 AC 96 ms
71,308 KB
testcase_02 AC 989 ms
100,732 KB
testcase_03 AC 698 ms
97,156 KB
testcase_04 AC 448 ms
90,624 KB
testcase_05 AC 332 ms
83,260 KB
testcase_06 AC 770 ms
98,220 KB
testcase_07 AC 621 ms
97,504 KB
testcase_08 AC 645 ms
97,916 KB
testcase_09 AC 621 ms
97,736 KB
testcase_10 AC 264 ms
88,884 KB
testcase_11 AC 259 ms
88,292 KB
testcase_12 AC 270 ms
90,204 KB
testcase_13 AC 193 ms
85,892 KB
testcase_14 AC 166 ms
81,632 KB
testcase_15 AC 213 ms
87,588 KB
testcase_16 AC 244 ms
86,460 KB
testcase_17 AC 142 ms
77,944 KB
testcase_18 AC 151 ms
79,548 KB
testcase_19 AC 443 ms
89,596 KB
testcase_20 AC 638 ms
95,704 KB
testcase_21 AC 612 ms
94,872 KB
testcase_22 AC 662 ms
96,024 KB
testcase_23 AC 571 ms
93,020 KB
testcase_24 AC 568 ms
93,180 KB
testcase_25 AC 637 ms
98,356 KB
testcase_26 AC 632 ms
95,728 KB
testcase_27 AC 272 ms
83,932 KB
testcase_28 AC 679 ms
99,268 KB
testcase_29 AC 652 ms
94,920 KB
testcase_30 AC 747 ms
97,460 KB
testcase_31 AC 740 ms
98,240 KB
testcase_32 AC 777 ms
101,216 KB
testcase_33 AC 657 ms
96,360 KB
testcase_34 AC 433 ms
87,312 KB
testcase_35 AC 437 ms
88,016 KB
testcase_36 AC 430 ms
90,656 KB
testcase_37 AC 568 ms
92,112 KB
testcase_38 AC 229 ms
81,204 KB
testcase_39 AC 251 ms
86,524 KB
testcase_40 AC 248 ms
86,936 KB
testcase_41 AC 205 ms
87,952 KB
testcase_42 AC 207 ms
87,584 KB
testcase_43 AC 603 ms
103,900 KB
testcase_44 AC 600 ms
103,456 KB
testcase_45 AC 596 ms
103,888 KB
testcase_46 AC 293 ms
90,176 KB
testcase_47 AC 336 ms
92,124 KB
testcase_48 AC 328 ms
92,840 KB
権限があれば一括ダウンロードができます

ソースコード

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]:
                ans[next]=max(cost,e_cost)
                root[next]=root[node]+1
                heappush(open,[max(cost,e_cost),next])
    return ans[-1]*-1
border=dijkstra(0,n,edge)
from collections import deque
que=deque([(0,0)])
visited=[-1]*n
while que:
    node,value=que.popleft()
    if visited[node]>=0:
        continue
    visited[node]=value
    for next,tmp in edge[node]:
        if -border>=tmp and visited[next]==-1:
            que.append((next,value+1))
print(border,visited[-1])
0