結果

問題 No.1473 おでぶなおばけさん
ユーザー NoaSaberNoaSaber
提出日時 2021-04-13 22:31:20
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,003 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 104,016 KB
最終ジャッジ日時 2023-09-12 13:20:19
合計ジャッジ時間 26,181 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 95 ms
71,732 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 657 ms
97,784 KB
testcase_08 AC 642 ms
98,104 KB
testcase_09 AC 638 ms
97,724 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 657 ms
96,368 KB
testcase_23 AC 573 ms
93,416 KB
testcase_24 AC 569 ms
93,344 KB
testcase_25 AC 636 ms
98,572 KB
testcase_26 AC 640 ms
95,860 KB
testcase_27 AC 274 ms
84,456 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 425 ms
91,184 KB
testcase_37 AC 555 ms
92,440 KB
testcase_38 AC 226 ms
81,356 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 209 ms
88,120 KB
testcase_42 AC 207 ms
88,256 KB
testcase_43 AC 596 ms
104,016 KB
testcase_44 AC 592 ms
103,832 KB
testcase_45 AC 599 ms
103,992 KB
testcase_46 AC 290 ms
90,256 KB
testcase_47 AC 330 ms
92,796 KB
testcase_48 AC 332 ms
92,680 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