結果

問題 No.1344 Typical Shortest Path Sum
ユーザー roarisroaris
提出日時 2021-01-24 05:46:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 560 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 86,608 KB
実行使用メモリ 76,884 KB
最終ジャッジ日時 2023-08-30 16:54:46
合計ジャッジ時間 10,397 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,016 KB
testcase_01 AC 72 ms
71,228 KB
testcase_02 AC 70 ms
71,020 KB
testcase_03 AC 77 ms
75,748 KB
testcase_04 AC 76 ms
75,820 KB
testcase_05 AC 71 ms
71,112 KB
testcase_06 AC 71 ms
71,192 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 75 ms
71,276 KB
testcase_10 AC 72 ms
71,396 KB
testcase_11 AC 73 ms
71,220 KB
testcase_12 WA -
testcase_13 AC 73 ms
71,224 KB
testcase_14 AC 72 ms
71,132 KB
testcase_15 AC 71 ms
71,132 KB
testcase_16 AC 81 ms
76,148 KB
testcase_17 AC 72 ms
71,172 KB
testcase_18 AC 69 ms
71,204 KB
testcase_19 AC 72 ms
70,940 KB
testcase_20 AC 73 ms
71,228 KB
testcase_21 AC 73 ms
71,232 KB
testcase_22 AC 71 ms
71,192 KB
testcase_23 AC 72 ms
71,172 KB
testcase_24 AC 72 ms
71,280 KB
testcase_25 AC 73 ms
71,136 KB
testcase_26 AC 72 ms
71,184 KB
testcase_27 AC 74 ms
71,280 KB
testcase_28 AC 73 ms
71,372 KB
testcase_29 AC 73 ms
71,180 KB
testcase_30 AC 73 ms
71,416 KB
testcase_31 AC 74 ms
71,320 KB
testcase_32 AC 70 ms
71,224 KB
testcase_33 AC 72 ms
71,052 KB
testcase_34 AC 71 ms
71,260 KB
testcase_35 AC 72 ms
71,220 KB
testcase_36 AC 70 ms
71,276 KB
testcase_37 AC 72 ms
71,276 KB
testcase_38 AC 72 ms
71,320 KB
testcase_39 AC 73 ms
71,024 KB
testcase_40 AC 88 ms
76,020 KB
testcase_41 AC 92 ms
76,132 KB
testcase_42 AC 88 ms
76,024 KB
testcase_43 AC 89 ms
76,016 KB
testcase_44 AC 87 ms
76,388 KB
testcase_45 AC 86 ms
76,160 KB
testcase_46 AC 88 ms
76,236 KB
testcase_47 AC 86 ms
76,080 KB
testcase_48 AC 89 ms
76,156 KB
testcase_49 AC 85 ms
75,908 KB
testcase_50 AC 86 ms
76,244 KB
testcase_51 AC 88 ms
76,088 KB
testcase_52 AC 90 ms
76,156 KB
testcase_53 AC 88 ms
76,164 KB
testcase_54 AC 83 ms
76,096 KB
testcase_55 AC 87 ms
76,160 KB
testcase_56 AC 88 ms
76,248 KB
testcase_57 AC 86 ms
76,240 KB
testcase_58 AC 89 ms
76,040 KB
testcase_59 AC 88 ms
76,100 KB
testcase_60 AC 80 ms
75,420 KB
testcase_61 AC 72 ms
71,188 KB
testcase_62 AC 104 ms
76,848 KB
testcase_63 AC 83 ms
75,984 KB
testcase_64 AC 85 ms
76,100 KB
testcase_65 AC 102 ms
76,844 KB
testcase_66 AC 100 ms
76,544 KB
testcase_67 AC 103 ms
76,884 KB
testcase_68 AC 84 ms
75,824 KB
testcase_69 AC 83 ms
75,984 KB
testcase_70 AC 78 ms
75,416 KB
testcase_71 AC 71 ms
71,328 KB
testcase_72 AC 72 ms
71,112 KB
testcase_73 AC 70 ms
71,188 KB
testcase_74 AC 70 ms
71,192 KB
testcase_75 AC 70 ms
71,068 KB
testcase_76 AC 68 ms
71,260 KB
testcase_77 AC 70 ms
71,412 KB
testcase_78 AC 70 ms
71,304 KB
testcase_79 AC 80 ms
76,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def warshall_floyd():
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if D[i][k]!=10**18 and D[k][j]!=10**18:
                    D[i][j] = min(D[i][j], D[i][k]+D[k][j])

N, M = map(int, input().split())
D = [[10**18]*N for _ in range(N)]

for i in range(N):
    D[i][i] = 0
    
for _ in range(M):
    s, t, d = map(int, input().split())
    D[s-1][t-1] = d

warshall_floyd()

for i in range(N):
    ans = 0
    
    for j in range(N):
        if D[i][j]!=10**18:
            ans += D[i][j]
    
    print(ans)
0