結果

問題 No.806 木を道に
ユーザー ducktailducktail
提出日時 2019-03-22 22:36:11
言語 Rust
(1.77.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 838 bytes
コンパイル時間 4,655 ms
コンパイル使用メモリ 163,344 KB
実行使用メモリ 9,412 KB
最終ジャッジ日時 2023-10-19 09:50:42
合計ジャッジ時間 5,182 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 0 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 0 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 9 ms
4,348 KB
testcase_11 AC 7 ms
4,348 KB
testcase_12 AC 37 ms
7,932 KB
testcase_13 AC 25 ms
6,084 KB
testcase_14 AC 36 ms
7,404 KB
testcase_15 AC 38 ms
7,932 KB
testcase_16 AC 12 ms
4,348 KB
testcase_17 AC 31 ms
7,140 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 9 ms
4,348 KB
testcase_20 AC 32 ms
7,140 KB
testcase_21 AC 16 ms
4,764 KB
testcase_22 AC 44 ms
8,988 KB
testcase_23 AC 44 ms
8,988 KB
testcase_24 AC 16 ms
5,556 KB
testcase_25 AC 23 ms
7,404 KB
testcase_26 AC 9 ms
4,348 KB
testcase_27 AC 28 ms
9,412 KB
testcase_28 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main(){
  let n: usize = read();
  let mut adl: Vec<Vec<usize>> = vec![Vec::new();n+1];

  for _ in 1 .. n {
    let ab: Vec<usize> = read_vec();
    let a = ab[0];
    let b = ab[1];
    adl[a].push(b);
    adl[b].push(a);
  }

  let mut ans: usize = 0;

  for i in 1 .. n+1 {
    if adl[i].len() > 2 {
      ans += adl[i].len() - 2;
    }
  }

  println!("{}", ans);
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}
0