結果
| 問題 |
No.872 All Tree Path
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-12 11:04:41 |
| 言語 | Ruby (3.4.1) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 379 bytes |
| コンパイル時間 | 266 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 825,380 KB |
| 最終ジャッジ日時 | 2024-11-24 19:58:14 |
| 合計ジャッジ時間 | 61,477 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 TLE * 1 MLE * 12 |
コンパイルメッセージ
Syntax OK
ソースコード
N = gets.to_i
dist = Array.new(N) {Array.new(N, Float::INFINITY)}
(N-1).times {
u, v, d = gets.split(" ").map{|s| s.to_i}
dist[u-1][v-1] = dist[v-1][u-1] = d
}
0.upto(N-1) {|k|
dist[k][k] = 0
0.upto(N-1) {|i|
0.upto(N-1) {|j|
dist[i][j] = [dist[i][j], dist[i][k] + dist[k][j]].min
}
}
}
cnt = 0
0.upto(N-1) {|i|
0.upto(N-1) {|j|
cnt += dist[i][j]
}
}
puts cnt