結果
問題 | No.1382 Travel in Mitaru city |
ユーザー | akakimidori |
提出日時 | 2021-02-07 20:40:03 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 2,219 bytes |
コンパイル時間 | 17,769 ms |
コンパイル使用メモリ | 377,496 KB |
実行使用メモリ | 14,404 KB |
最終ジャッジ日時 | 2024-07-04 13:42:51 |
合計ジャッジ時間 | 22,283 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 68 |
コンパイルメッセージ
warning: unused import: `std::cmp::*` --> src/main.rs:51:5 | 51 | use std::cmp::*; | ^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused variable: `t` --> src/main.rs:58:9 | 58 | t: usize1, | ^ | help: `t` is captured in macro and introduced a unused variable --> src/main.rs:24:13 | 24 | let $var = read_value!($iter, $t); | ^^^^ ... 54 | / input! { 55 | | n: usize, 56 | | m: usize, 57 | | s: usize1, ... | 60 | | e: [(usize1, usize1); m], 61 | | } | |_____- in this macro invocation = note: `#[warn(unused_variables)]` on by default = note: this warning originates in the macro `input_inner` which comes from the expansion of the macro `input` (in Nightly builds, run with -Z macro-backtrace for more info)
ソースコード
// ---------- begin input macro ---------- // reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::<Vec<char>>() }; ($iter:expr, bytes) => { read_value!($iter, String).bytes().collect::<Vec<u8>>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } // ---------- end input macro ---------- use std::cmp::*; fn run() { input! { n: usize, m: usize, s: usize1, t: usize1, p: [u32; n], e: [(usize1, usize1); m], } let mut g = vec![vec![]; n]; for (a, b) in e { g[a].push(b); g[b].push(a); } let mut used = vec![false; n]; let mut now = p[s]; let mut h = std::collections::BinaryHeap::new(); h.push((now, s)); let mut ans = 0; while let Some((a, v)) = h.pop() { if used[v] { continue; } used[v] = true; if a < now { now = a; ans += 1; } for &u in g[v].iter() { if !used[u] { h.push((p[u], u)); } } } println!("{}", ans); } fn main() { run(); }