結果

問題 No.1382 Travel in Mitaru city
ユーザー akakimidoriakakimidori
提出日時 2021-02-07 20:40:03
言語 Rust
(1.77.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 2,219 bytes
コンパイル時間 1,422 ms
コンパイル使用メモリ 150,072 KB
実行使用メモリ 14,964 KB
最終ジャッジ日時 2023-09-17 19:23:12
合計ジャッジ時間 6,416 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 29 ms
7,112 KB
testcase_07 AC 22 ms
5,952 KB
testcase_08 AC 11 ms
4,376 KB
testcase_09 AC 33 ms
8,340 KB
testcase_10 AC 31 ms
7,004 KB
testcase_11 AC 35 ms
9,436 KB
testcase_12 AC 35 ms
9,428 KB
testcase_13 AC 40 ms
9,708 KB
testcase_14 AC 32 ms
9,172 KB
testcase_15 AC 34 ms
9,168 KB
testcase_16 AC 57 ms
14,452 KB
testcase_17 AC 58 ms
14,436 KB
testcase_18 AC 57 ms
14,336 KB
testcase_19 AC 57 ms
14,416 KB
testcase_20 AC 58 ms
14,396 KB
testcase_21 AC 56 ms
14,408 KB
testcase_22 AC 55 ms
14,432 KB
testcase_23 AC 56 ms
14,436 KB
testcase_24 AC 57 ms
14,432 KB
testcase_25 AC 57 ms
14,384 KB
testcase_26 AC 52 ms
14,360 KB
testcase_27 AC 53 ms
14,428 KB
testcase_28 AC 53 ms
14,460 KB
testcase_29 AC 55 ms
14,468 KB
testcase_30 AC 54 ms
14,356 KB
testcase_31 AC 29 ms
11,256 KB
testcase_32 AC 38 ms
14,964 KB
testcase_33 AC 36 ms
12,380 KB
testcase_34 AC 23 ms
9,696 KB
testcase_35 AC 15 ms
6,840 KB
testcase_36 AC 22 ms
11,460 KB
testcase_37 AC 4 ms
4,380 KB
testcase_38 AC 24 ms
12,316 KB
testcase_39 AC 7 ms
4,460 KB
testcase_40 AC 18 ms
10,224 KB
testcase_41 AC 20 ms
11,040 KB
testcase_42 AC 23 ms
12,252 KB
testcase_43 AC 21 ms
11,272 KB
testcase_44 AC 9 ms
5,780 KB
testcase_45 AC 19 ms
10,432 KB
testcase_46 AC 14 ms
5,720 KB
testcase_47 AC 53 ms
13,772 KB
testcase_48 AC 34 ms
10,536 KB
testcase_49 AC 57 ms
14,516 KB
testcase_50 AC 22 ms
7,708 KB
testcase_51 AC 29 ms
11,564 KB
testcase_52 AC 38 ms
12,828 KB
testcase_53 AC 8 ms
4,380 KB
testcase_54 AC 15 ms
7,080 KB
testcase_55 AC 41 ms
12,624 KB
testcase_56 AC 11 ms
6,052 KB
testcase_57 AC 22 ms
9,628 KB
testcase_58 AC 4 ms
4,380 KB
testcase_59 AC 11 ms
5,792 KB
testcase_60 AC 35 ms
12,348 KB
testcase_61 AC 2 ms
4,376 KB
testcase_62 AC 1 ms
4,380 KB
testcase_63 AC 8 ms
4,380 KB
testcase_64 AC 2 ms
4,380 KB
testcase_65 AC 1 ms
4,376 KB
testcase_66 AC 2 ms
4,376 KB
testcase_67 AC 2 ms
4,376 KB
testcase_68 AC 4 ms
4,376 KB
testcase_69 AC 2 ms
4,376 KB
testcase_70 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::cmp::*`
  --> Main.rs:51:5
   |
51 | use std::cmp::*;
   |     ^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused variable: `t`
  --> Main.rs:58:9
   |
58 |         t: usize1,
   |         ^ help: if this is intentional, prefix it with an underscore: `_t`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: 2 warnings emitted

ソースコード

diff #

// ---------- 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();
}
0