結果

問題 No.1344 Typical Shortest Path Sum
ユーザー nasubi24nasubi24
提出日時 2021-01-16 14:52:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 928 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 23,068 KB
最終ジャッジ日時 2024-05-05 17:30:05
合計ジャッジ時間 6,868 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
16,256 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 31 ms
10,752 KB
testcase_04 AC 31 ms
10,880 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 AC 31 ms
10,880 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 AC 31 ms
10,752 KB
testcase_10 AC 31 ms
10,752 KB
testcase_11 AC 36 ms
10,880 KB
testcase_12 AC 31 ms
10,752 KB
testcase_13 AC 32 ms
10,752 KB
testcase_14 AC 31 ms
10,752 KB
testcase_15 AC 31 ms
10,880 KB
testcase_16 AC 34 ms
10,880 KB
testcase_17 AC 31 ms
10,752 KB
testcase_18 AC 32 ms
10,880 KB
testcase_19 AC 31 ms
10,880 KB
testcase_20 AC 31 ms
10,752 KB
testcase_21 AC 31 ms
10,880 KB
testcase_22 AC 31 ms
10,880 KB
testcase_23 AC 32 ms
10,880 KB
testcase_24 AC 31 ms
10,752 KB
testcase_25 AC 31 ms
10,880 KB
testcase_26 AC 31 ms
10,880 KB
testcase_27 AC 31 ms
10,752 KB
testcase_28 AC 31 ms
10,752 KB
testcase_29 AC 31 ms
10,752 KB
testcase_30 AC 31 ms
10,880 KB
testcase_31 AC 31 ms
10,880 KB
testcase_32 AC 31 ms
10,752 KB
testcase_33 AC 31 ms
10,880 KB
testcase_34 AC 31 ms
10,752 KB
testcase_35 AC 32 ms
10,880 KB
testcase_36 AC 31 ms
10,880 KB
testcase_37 AC 32 ms
10,752 KB
testcase_38 AC 30 ms
10,880 KB
testcase_39 AC 31 ms
10,880 KB
testcase_40 AC 38 ms
11,264 KB
testcase_41 AC 39 ms
11,520 KB
testcase_42 AC 38 ms
11,392 KB
testcase_43 AC 37 ms
11,264 KB
testcase_44 AC 37 ms
11,264 KB
testcase_45 AC 38 ms
11,264 KB
testcase_46 AC 39 ms
11,392 KB
testcase_47 AC 37 ms
11,264 KB
testcase_48 AC 39 ms
11,392 KB
testcase_49 AC 38 ms
11,264 KB
testcase_50 AC 37 ms
11,392 KB
testcase_51 AC 38 ms
11,392 KB
testcase_52 AC 38 ms
11,392 KB
testcase_53 AC 41 ms
11,392 KB
testcase_54 AC 37 ms
11,264 KB
testcase_55 AC 38 ms
11,264 KB
testcase_56 AC 39 ms
11,264 KB
testcase_57 AC 38 ms
11,264 KB
testcase_58 AC 39 ms
11,648 KB
testcase_59 AC 39 ms
11,392 KB
testcase_60 AC 74 ms
10,880 KB
testcase_61 AC 32 ms
10,752 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 #

from collections import deque
n,m=map(int,input().split())
num=[[[] for _ in range(n)] for z in range(n)]
for i in range(m):
    s,t,d=map(int,input().split())
    num[s-1][t-1].append(d)
num2=[[] for _ in range(n)]
for i in range(n):
    for j in range(n):
        if len(num[i][j])!=0:
            num2[i].append([j,min(num[i][j])])
for i in range(n):
    queue=deque()
    ans=[10**18]*n
    ans[i]=0
    queue.append(i)
    while len(queue)!=0:
        num1=queue.popleft()
        num3=ans[num1]
        num4=num2[num1]
        for j in range(len(num4)):
            if ans[num4[j][0]]==10**18:
                ans[num4[j][0]]=num3+num4[j][1]
                queue.append(num4[j][0])
            if ans[num4[j][0]]>num3+num4[j][1]:
                ans[num4[j][0]]=num3+num4[j][1]
                queue.append(num4[j][0])
    ans2=0
    for j in range(n):
        if ans[j]!=10**18:
            ans2+=ans[j]
    print(ans2)
0