結果

問題 No.1344 Typical Shortest Path Sum
ユーザー tonyu0
提出日時 2021-01-16 18:04:27
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 998 bytes
コンパイル時間 12,927 ms
コンパイル使用メモリ 401,068 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-27 22:33:03
合計ジャッジ時間 15,394 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 51
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `i`
  --> src/main.rs:13:9
   |
13 |     for i in 0..m {
   |         ^ help: if this is intentional, prefix it with an underscore: `_i`
   |
   = note: `#[warn(unused_variables)]` on by default

ソースコード

diff #

use std::io::*;
const INF: i64 = 1i64 << 60;
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let mut d = vec![vec![INF; n]; n];
    for i in 0..n {
        d[i][i] = 0;
    }
    for i in 0..m {
        let s = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let t = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let x: i64 = itr.next().unwrap().parse().unwrap();
        d[s][t] = x;
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                d[i][j] = std::cmp::min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    for i in 0..n {
        let mut ans = 0;
        for j in 0..n {
            if d[i][j] != INF {
                ans += d[i][j];
            }
        }
        println!("{}", ans);
    }
}
0