結果
| 問題 |
No.1344 Typical Shortest Path Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-16 14:29:09 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,227 bytes |
| コンパイル時間 | 12,842 ms |
| コンパイル使用メモリ | 434,056 KB |
| 実行使用メモリ | 79,196 KB |
| 最終ジャッジ日時 | 2024-11-27 16:06:47 |
| 合計ジャッジ時間 | 37,121 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 49 |
ソースコード
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) {
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