結果

問題 No.1344 Typical Shortest Path Sum
ユーザー titiatitia
提出日時 2021-01-16 13:13:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 86,864 KB
実行使用メモリ 78,248 KB
最終ジャッジ日時 2023-08-18 09:23:36
合計ジャッジ時間 10,267 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,184 KB
testcase_01 AC 71 ms
71,240 KB
testcase_02 AC 71 ms
71,432 KB
testcase_03 AC 94 ms
76,816 KB
testcase_04 AC 86 ms
76,588 KB
testcase_05 AC 74 ms
71,252 KB
testcase_06 AC 74 ms
71,416 KB
testcase_07 AC 73 ms
71,412 KB
testcase_08 AC 73 ms
71,416 KB
testcase_09 AC 73 ms
71,296 KB
testcase_10 AC 72 ms
71,104 KB
testcase_11 AC 74 ms
71,576 KB
testcase_12 AC 75 ms
71,648 KB
testcase_13 AC 72 ms
71,400 KB
testcase_14 AC 72 ms
71,444 KB
testcase_15 AC 74 ms
71,132 KB
testcase_16 AC 117 ms
77,668 KB
testcase_17 AC 75 ms
71,384 KB
testcase_18 AC 70 ms
71,248 KB
testcase_19 AC 70 ms
71,128 KB
testcase_20 AC 71 ms
71,436 KB
testcase_21 AC 73 ms
71,236 KB
testcase_22 AC 72 ms
71,100 KB
testcase_23 AC 72 ms
71,420 KB
testcase_24 AC 72 ms
71,412 KB
testcase_25 AC 72 ms
71,624 KB
testcase_26 AC 73 ms
71,388 KB
testcase_27 AC 74 ms
71,236 KB
testcase_28 AC 72 ms
71,604 KB
testcase_29 AC 72 ms
71,528 KB
testcase_30 AC 73 ms
71,448 KB
testcase_31 AC 75 ms
71,276 KB
testcase_32 AC 73 ms
71,480 KB
testcase_33 AC 74 ms
71,416 KB
testcase_34 AC 73 ms
71,532 KB
testcase_35 AC 72 ms
71,452 KB
testcase_36 AC 71 ms
71,460 KB
testcase_37 AC 72 ms
71,300 KB
testcase_38 AC 71 ms
71,384 KB
testcase_39 AC 72 ms
71,572 KB
testcase_40 AC 135 ms
77,864 KB
testcase_41 AC 142 ms
77,988 KB
testcase_42 AC 138 ms
77,680 KB
testcase_43 AC 138 ms
77,504 KB
testcase_44 AC 139 ms
77,868 KB
testcase_45 AC 144 ms
77,980 KB
testcase_46 AC 136 ms
78,248 KB
testcase_47 AC 134 ms
77,688 KB
testcase_48 AC 140 ms
77,924 KB
testcase_49 AC 133 ms
77,868 KB
testcase_50 AC 138 ms
77,936 KB
testcase_51 AC 146 ms
77,832 KB
testcase_52 AC 136 ms
77,720 KB
testcase_53 AC 143 ms
77,892 KB
testcase_54 AC 131 ms
77,776 KB
testcase_55 AC 138 ms
77,896 KB
testcase_56 AC 138 ms
77,952 KB
testcase_57 AC 133 ms
77,840 KB
testcase_58 AC 140 ms
78,140 KB
testcase_59 AC 139 ms
78,176 KB
testcase_60 AC 79 ms
76,256 KB
testcase_61 AC 75 ms
71,444 KB
testcase_62 AC 99 ms
77,060 KB
testcase_63 AC 80 ms
76,500 KB
testcase_64 AC 83 ms
76,384 KB
testcase_65 AC 94 ms
77,092 KB
testcase_66 AC 93 ms
77,224 KB
testcase_67 AC 93 ms
76,764 KB
testcase_68 AC 80 ms
76,520 KB
testcase_69 AC 83 ms
76,420 KB
testcase_70 AC 89 ms
76,332 KB
testcase_71 AC 76 ms
71,384 KB
testcase_72 AC 74 ms
71,408 KB
testcase_73 AC 75 ms
71,304 KB
testcase_74 AC 73 ms
71,612 KB
testcase_75 AC 75 ms
71,632 KB
testcase_76 AC 75 ms
71,132 KB
testcase_77 AC 75 ms
71,432 KB
testcase_78 AC 77 ms
71,644 KB
testcase_79 AC 92 ms
76,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,M=map(int,input().split())
E=[[] for i in range(N)]

Distance=[[float("inf") for i in range(N)] for j in range(N)]

for i in range(N):
    Distance[i][i]=0

for i in range(M):
    s,t,d=map(int,input().split())
    s-=1
    t-=1
    E[s].append((t,d))
    Distance[s][t]=min(Distance[s][t],d)

for k in range(N): # k個までの町を使ってのDisが知れているときに
    for i in range(N): # 町iと
        for j in range(N): # 町jとの最短距離は、
            length=Distance[i][k]+Distance[k][j]
            if Distance[i][j]>length:
                Distance[i][j]=length

for i in range(N):
    S=0
    for j in range(N):
        if Distance[i][j]==float("inf"):
            True
        else:
            S+=Distance[i][j]
    print(S)
0