結果
問題 | No.1344 Typical Shortest Path Sum |
ユーザー | 箱星 |
提出日時 | 2021-01-16 14:32:46 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 348 ms / 2,000 ms |
コード長 | 1,311 bytes |
コンパイル時間 | 17,256 ms |
コンパイル使用メモリ | 441,176 KB |
実行使用メモリ | 55,052 KB |
最終ジャッジ日時 | 2024-11-27 16:19:51 |
合計ジャッジ時間 | 40,983 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 277 ms
53,704 KB |
testcase_01 | AC | 277 ms
53,628 KB |
testcase_02 | AC | 274 ms
52,748 KB |
testcase_03 | AC | 278 ms
52,660 KB |
testcase_04 | AC | 280 ms
52,884 KB |
testcase_05 | AC | 278 ms
52,844 KB |
testcase_06 | AC | 279 ms
52,916 KB |
testcase_07 | AC | 281 ms
52,940 KB |
testcase_08 | AC | 280 ms
52,904 KB |
testcase_09 | AC | 280 ms
52,964 KB |
testcase_10 | AC | 277 ms
52,912 KB |
testcase_11 | AC | 275 ms
53,028 KB |
testcase_12 | AC | 277 ms
52,980 KB |
testcase_13 | AC | 279 ms
52,996 KB |
testcase_14 | AC | 279 ms
52,800 KB |
testcase_15 | AC | 277 ms
53,140 KB |
testcase_16 | AC | 303 ms
53,136 KB |
testcase_17 | AC | 279 ms
52,984 KB |
testcase_18 | AC | 279 ms
52,728 KB |
testcase_19 | AC | 280 ms
52,956 KB |
testcase_20 | AC | 279 ms
52,880 KB |
testcase_21 | AC | 282 ms
52,908 KB |
testcase_22 | AC | 309 ms
52,872 KB |
testcase_23 | AC | 281 ms
52,856 KB |
testcase_24 | AC | 279 ms
52,888 KB |
testcase_25 | AC | 276 ms
52,880 KB |
testcase_26 | AC | 277 ms
52,776 KB |
testcase_27 | AC | 276 ms
52,716 KB |
testcase_28 | AC | 275 ms
52,816 KB |
testcase_29 | AC | 273 ms
52,864 KB |
testcase_30 | AC | 276 ms
52,716 KB |
testcase_31 | AC | 275 ms
52,896 KB |
testcase_32 | AC | 275 ms
52,616 KB |
testcase_33 | AC | 272 ms
52,992 KB |
testcase_34 | AC | 270 ms
52,976 KB |
testcase_35 | AC | 275 ms
52,756 KB |
testcase_36 | AC | 278 ms
52,768 KB |
testcase_37 | AC | 276 ms
52,848 KB |
testcase_38 | AC | 278 ms
52,700 KB |
testcase_39 | AC | 276 ms
52,900 KB |
testcase_40 | AC | 308 ms
53,640 KB |
testcase_41 | AC | 309 ms
52,224 KB |
testcase_42 | AC | 311 ms
53,372 KB |
testcase_43 | AC | 316 ms
53,604 KB |
testcase_44 | AC | 305 ms
53,520 KB |
testcase_45 | AC | 312 ms
53,636 KB |
testcase_46 | AC | 326 ms
53,548 KB |
testcase_47 | AC | 305 ms
53,504 KB |
testcase_48 | AC | 311 ms
53,344 KB |
testcase_49 | AC | 318 ms
53,696 KB |
testcase_50 | AC | 331 ms
53,396 KB |
testcase_51 | AC | 309 ms
53,436 KB |
testcase_52 | AC | 306 ms
53,644 KB |
testcase_53 | AC | 310 ms
53,620 KB |
testcase_54 | AC | 307 ms
53,548 KB |
testcase_55 | AC | 302 ms
53,624 KB |
testcase_56 | AC | 309 ms
53,560 KB |
testcase_57 | AC | 305 ms
53,400 KB |
testcase_58 | AC | 316 ms
53,480 KB |
testcase_59 | AC | 306 ms
53,492 KB |
testcase_60 | AC | 283 ms
52,952 KB |
testcase_61 | AC | 276 ms
52,988 KB |
testcase_62 | AC | 334 ms
55,016 KB |
testcase_63 | AC | 301 ms
53,520 KB |
testcase_64 | AC | 306 ms
53,516 KB |
testcase_65 | AC | 348 ms
55,052 KB |
testcase_66 | AC | 337 ms
54,792 KB |
testcase_67 | AC | 339 ms
54,784 KB |
testcase_68 | AC | 297 ms
53,080 KB |
testcase_69 | AC | 293 ms
53,452 KB |
testcase_70 | AC | 277 ms
52,668 KB |
testcase_71 | AC | 274 ms
52,756 KB |
testcase_72 | AC | 278 ms
52,756 KB |
testcase_73 | AC | 277 ms
49,688 KB |
testcase_74 | AC | 277 ms
49,664 KB |
testcase_75 | AC | 277 ms
49,848 KB |
testcase_76 | AC | 276 ms
49,840 KB |
testcase_77 | AC | 278 ms
49,924 KB |
testcase_78 | AC | 279 ms
49,804 KB |
testcase_79 | AC | 281 ms
49,880 KB |
ソースコード
import java.io.PrintWriter import java.util.* import kotlin.math.* fun PrintWriter.solve() { val n = nextInt() val m = nextInt() val INF = 1000000000000000000 val dist = Array(n) { Array(n) { INF } } for (i in 0 until m) { val s = nextInt() - 1 val t = nextInt() - 1 val d = nextLong() dist[s][t] = min(dist[s][t], d) } for (k in 0 until n) { for (i in 0 until n) { for (j in 0 until n) { if (dist[i][k] != INF && dist[k][j] != INF) { dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) } } } } for (i in 0 until n) { var sum = 0L for (j in 0 until n) { sum += if (i == j || dist[i][j] == INF) 0 else dist[i][j] } println(sum) } } fun main() { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine()!! fun nextDouble() = next().toDouble() // endregion