結果
問題 | No.1601 With Animals into Institute |
ユーザー | sapphire__15 |
提出日時 | 2021-07-10 15:19:02 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 577 ms / 3,000 ms |
コード長 | 1,993 bytes |
コンパイル時間 | 13,283 ms |
コンパイル使用メモリ | 379,460 KB |
実行使用メモリ | 38,144 KB |
最終ジャッジ日時 | 2024-07-02 02:31:07 |
合計ジャッジ時間 | 21,532 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 5 ms
5,376 KB |
testcase_04 | AC | 5 ms
5,376 KB |
testcase_05 | AC | 6 ms
5,376 KB |
testcase_06 | AC | 514 ms
37,632 KB |
testcase_07 | AC | 519 ms
37,632 KB |
testcase_08 | AC | 509 ms
37,504 KB |
testcase_09 | AC | 542 ms
38,144 KB |
testcase_10 | AC | 577 ms
38,144 KB |
testcase_11 | AC | 532 ms
38,144 KB |
testcase_12 | AC | 556 ms
38,016 KB |
testcase_13 | AC | 539 ms
38,144 KB |
testcase_14 | AC | 546 ms
37,888 KB |
testcase_15 | AC | 534 ms
37,888 KB |
testcase_16 | AC | 523 ms
38,016 KB |
testcase_17 | AC | 511 ms
37,760 KB |
testcase_18 | AC | 6 ms
5,376 KB |
testcase_19 | AC | 6 ms
5,376 KB |
testcase_20 | AC | 6 ms
5,376 KB |
testcase_21 | AC | 5 ms
5,376 KB |
testcase_22 | AC | 6 ms
5,376 KB |
testcase_23 | AC | 6 ms
5,376 KB |
testcase_24 | AC | 6 ms
5,376 KB |
testcase_25 | AC | 6 ms
5,376 KB |
testcase_26 | AC | 6 ms
5,376 KB |
testcase_27 | AC | 1 ms
5,376 KB |
testcase_28 | AC | 1 ms
5,376 KB |
testcase_29 | AC | 1 ms
5,376 KB |
testcase_30 | AC | 1 ms
5,376 KB |
testcase_31 | AC | 1 ms
5,376 KB |
testcase_32 | AC | 1 ms
5,376 KB |
testcase_33 | AC | 1 ms
5,376 KB |
testcase_34 | AC | 1 ms
5,376 KB |
testcase_35 | AC | 1 ms
5,376 KB |
testcase_36 | AC | 1 ms
5,376 KB |
testcase_37 | AC | 1 ms
5,376 KB |
testcase_38 | AC | 1 ms
5,376 KB |
ソースコード
// -*- coding:utf-8-unix -*- use std::cmp::Ordering; use proconio::input; use std::collections::BinaryHeap; #[derive(Debug)] struct Edge { to: usize, length: i64 } #[derive(Debug)] struct Entry { to: usize, length: i64 } impl PartialEq for Entry { fn eq(&self, other: &Self) -> bool { self.length == other.length } } impl Eq for Entry {} impl PartialOrd for Entry { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { other.length.partial_cmp(&self.length) } } impl Ord for Entry { fn cmp(&self, other: &Self) -> Ordering { self.length.cmp(&other.length) } } fn main() { input! { n: usize, m: usize, } let mut da: Vec<Vec<Edge>> = Vec::new(); for _ in 0..n * 2 { da.push(Vec::new()); } for _ in 0..m { input! { a: usize, b: usize, c: i64, x: i32, } da[n + a - 1].push(Edge { to: n + b - 1, length: c }); da[n + b - 1].push(Edge { to: n + a - 1, length: c }); if x == 1 { da[n + a - 1].push(Edge { to: b - 1, length: c }); da[n + b - 1].push(Edge { to: a - 1, length: c }); } else { da[a - 1].push(Edge { to: b - 1, length: c }); da[b - 1].push(Edge { to: a - 1, length: c }); } } let mut used = Vec::new(); used.resize(n*2, -1); let mut pq = BinaryHeap::new(); pq.push(Entry{ to: n*2-1, length: 0}); loop { let now = pq.pop(); match now { None => break, Some(x) => { if used[x.to] < 0 { used[x.to] = x.length; for to in &da[x.to] { pq.push(Entry {to: to.to, length: x.length + to.length }); } } } } } for i in 0..n-1 { println!("{}", used[i]); } }