結果
問題 | No.806 木を道に |
ユーザー |
|
提出日時 | 2019-03-22 22:36:11 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 838 bytes |
コンパイル時間 | 11,786 ms |
コンパイル使用メモリ | 401,744 KB |
実行使用メモリ | 9,472 KB |
最終ジャッジ日時 | 2024-09-19 06:03:04 |
合計ジャッジ時間 | 13,401 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
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() }