結果

問題 No.1344 Typical Shortest Path Sum
ユーザー Omura ShunsukeOmura Shunsuke
提出日時 2021-01-16 16:09:36
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 654 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 87,312 KB
実行使用メモリ 430,832 KB
最終ジャッジ日時 2023-08-18 13:50:30
合計ジャッジ時間 12,325 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,232 KB
testcase_01 AC 76 ms
71,564 KB
testcase_02 AC 76 ms
71,548 KB
testcase_03 AC 75 ms
71,380 KB
testcase_04 AC 76 ms
71,584 KB
testcase_05 AC 76 ms
71,240 KB
testcase_06 AC 75 ms
71,432 KB
testcase_07 AC 74 ms
71,600 KB
testcase_08 AC 75 ms
71,408 KB
testcase_09 AC 76 ms
71,584 KB
testcase_10 AC 75 ms
71,584 KB
testcase_11 AC 76 ms
71,188 KB
testcase_12 AC 75 ms
71,632 KB
testcase_13 AC 77 ms
71,604 KB
testcase_14 AC 77 ms
71,216 KB
testcase_15 AC 74 ms
71,212 KB
testcase_16 AC 83 ms
76,156 KB
testcase_17 AC 76 ms
71,444 KB
testcase_18 AC 77 ms
71,232 KB
testcase_19 AC 76 ms
71,576 KB
testcase_20 AC 76 ms
71,404 KB
testcase_21 AC 77 ms
71,688 KB
testcase_22 AC 77 ms
71,392 KB
testcase_23 AC 78 ms
71,584 KB
testcase_24 AC 78 ms
71,512 KB
testcase_25 AC 77 ms
71,480 KB
testcase_26 AC 76 ms
71,584 KB
testcase_27 AC 77 ms
71,384 KB
testcase_28 AC 77 ms
71,440 KB
testcase_29 AC 75 ms
71,472 KB
testcase_30 AC 76 ms
71,212 KB
testcase_31 AC 75 ms
71,448 KB
testcase_32 AC 77 ms
71,492 KB
testcase_33 AC 76 ms
71,616 KB
testcase_34 AC 75 ms
71,608 KB
testcase_35 AC 75 ms
71,236 KB
testcase_36 AC 76 ms
71,544 KB
testcase_37 AC 77 ms
71,400 KB
testcase_38 AC 76 ms
71,236 KB
testcase_39 AC 75 ms
71,580 KB
testcase_40 AC 88 ms
76,168 KB
testcase_41 AC 86 ms
76,320 KB
testcase_42 AC 86 ms
76,308 KB
testcase_43 AC 85 ms
76,336 KB
testcase_44 AC 84 ms
76,252 KB
testcase_45 AC 86 ms
76,160 KB
testcase_46 AC 85 ms
76,348 KB
testcase_47 AC 87 ms
76,332 KB
testcase_48 AC 90 ms
76,168 KB
testcase_49 AC 87 ms
76,320 KB
testcase_50 AC 85 ms
76,188 KB
testcase_51 AC 86 ms
76,300 KB
testcase_52 AC 84 ms
76,276 KB
testcase_53 AC 115 ms
77,864 KB
testcase_54 AC 85 ms
76,204 KB
testcase_55 AC 86 ms
76,212 KB
testcase_56 AC 90 ms
76,072 KB
testcase_57 AC 88 ms
76,184 KB
testcase_58 AC 90 ms
76,236 KB
testcase_59 AC 86 ms
76,028 KB
testcase_60 AC 264 ms
80,000 KB
testcase_61 AC 79 ms
71,484 KB
testcase_62 TLE -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
L=[{}for i in range(N+1)]

for i in range(M):
    a,b,c=map(int,input().split())
    if b in L[a]:
        L[a][b] = min(L[a][b],c)
    else:
        L[a][b] = c
#print(L)

import heapq

for i in range(1,N+1):
    dist=[10**20 for i in range(N+1)]
    s=i
    Q=[(0,s)]
    heapq.heapify(Q)
    while len(Q)>0:
        d,p=heapq.heappop(Q)
        if dist[p]>d:
            dist[p]=d
            for k,v in L[p].items():
                if dist[k]>(v+d):
                    heapq.heappush(Q,(v+d,k))
    ans=0
    for i in dist[1:]:
        if i==10**20:
            continue
        else:
            ans+=i
    print(ans)
0