結果

問題 No.1344 Typical Shortest Path Sum
ユーザー qibqib
提出日時 2022-11-25 15:25:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 75,036 KB
最終ジャッジ日時 2024-04-09 22:18:47
合計ジャッジ時間 5,130 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
53,420 KB
testcase_01 AC 31 ms
52,680 KB
testcase_02 AC 30 ms
52,124 KB
testcase_03 AC 38 ms
61,628 KB
testcase_04 AC 38 ms
60,976 KB
testcase_05 AC 31 ms
52,960 KB
testcase_06 AC 33 ms
53,700 KB
testcase_07 AC 31 ms
52,372 KB
testcase_08 AC 31 ms
52,464 KB
testcase_09 AC 32 ms
52,720 KB
testcase_10 AC 33 ms
52,952 KB
testcase_11 AC 32 ms
53,020 KB
testcase_12 AC 31 ms
53,072 KB
testcase_13 AC 32 ms
52,252 KB
testcase_14 AC 32 ms
53,136 KB
testcase_15 AC 32 ms
53,076 KB
testcase_16 AC 42 ms
62,496 KB
testcase_17 AC 33 ms
52,628 KB
testcase_18 AC 35 ms
52,676 KB
testcase_19 AC 35 ms
52,820 KB
testcase_20 AC 33 ms
53,140 KB
testcase_21 AC 32 ms
52,808 KB
testcase_22 AC 35 ms
53,272 KB
testcase_23 AC 36 ms
53,948 KB
testcase_24 AC 35 ms
52,692 KB
testcase_25 AC 32 ms
52,464 KB
testcase_26 AC 31 ms
52,288 KB
testcase_27 AC 32 ms
53,216 KB
testcase_28 AC 32 ms
52,508 KB
testcase_29 AC 34 ms
52,484 KB
testcase_30 AC 34 ms
52,992 KB
testcase_31 AC 33 ms
53,948 KB
testcase_32 AC 32 ms
52,560 KB
testcase_33 AC 32 ms
52,072 KB
testcase_34 AC 33 ms
52,688 KB
testcase_35 AC 33 ms
52,012 KB
testcase_36 AC 33 ms
53,084 KB
testcase_37 AC 33 ms
53,948 KB
testcase_38 AC 33 ms
53,028 KB
testcase_39 AC 36 ms
53,932 KB
testcase_40 AC 52 ms
65,744 KB
testcase_41 AC 54 ms
66,112 KB
testcase_42 AC 53 ms
65,088 KB
testcase_43 AC 51 ms
64,500 KB
testcase_44 AC 50 ms
64,472 KB
testcase_45 AC 52 ms
64,456 KB
testcase_46 AC 49 ms
65,092 KB
testcase_47 AC 49 ms
65,060 KB
testcase_48 AC 50 ms
65,176 KB
testcase_49 AC 50 ms
64,084 KB
testcase_50 AC 47 ms
64,140 KB
testcase_51 AC 55 ms
64,796 KB
testcase_52 AC 48 ms
64,688 KB
testcase_53 AC 50 ms
65,440 KB
testcase_54 AC 47 ms
64,504 KB
testcase_55 AC 51 ms
64,480 KB
testcase_56 AC 50 ms
65,052 KB
testcase_57 AC 48 ms
64,496 KB
testcase_58 AC 50 ms
64,792 KB
testcase_59 AC 50 ms
64,780 KB
testcase_60 AC 45 ms
62,268 KB
testcase_61 AC 37 ms
52,392 KB
testcase_62 AC 66 ms
75,036 KB
testcase_63 AC 44 ms
62,836 KB
testcase_64 AC 47 ms
63,484 KB
testcase_65 AC 64 ms
74,920 KB
testcase_66 AC 64 ms
74,216 KB
testcase_67 AC 65 ms
73,608 KB
testcase_68 AC 44 ms
63,128 KB
testcase_69 AC 42 ms
62,648 KB
testcase_70 AC 42 ms
59,708 KB
testcase_71 AC 35 ms
52,404 KB
testcase_72 AC 36 ms
53,716 KB
testcase_73 AC 34 ms
53,272 KB
testcase_74 AC 34 ms
52,952 KB
testcase_75 AC 36 ms
53,344 KB
testcase_76 AC 35 ms
53,352 KB
testcase_77 AC 34 ms
53,316 KB
testcase_78 AC 33 ms
54,176 KB
testcase_79 AC 43 ms
62,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 1 << 60

n, m = map(int, input().split())
dist = [[INF for _ in range(n)] for _ in range(n)]
for v in range(n):
  dist[v][v] = 0

for _ in range(m):
  s, t, d = map(int, input().split())
  s -= 1
  t -= 1
  dist[s][t] = min(dist[s][t], d)

for k in range(n):
  dk = dist[k]
  for u in range(n):
    du = dist[u]
    for v in range(n):
      if du[k] < INF and dk[v] < INF and du[v] > du[k] + dk[v]:
        du[v] = du[k] + dk[v]

for i in range(n):
  ans = 0
  for j in range(n):
    if dist[i][j] < INF:
      ans += dist[i][j]
  print(ans)
0