結果
問題 |
No.806 木を道に
|
ユーザー |
|
提出日時 | 2019-08-13 23:29:15 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 990 bytes |
コンパイル時間 | 14,397 ms |
コンパイル使用メモリ | 378,736 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 13:37:21 |
合計ジャッジ時間 | 15,923 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 WA * 13 |
ソースコード
use std::collections::HashMap; fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } fn main() { let peak_max: usize = read(); let mut peaks = HashMap::new(); loop { let input: Vec<u32> = read_vec(); { let e = peaks.entry(input[0]).or_insert(0); *e += 1; } { let e = peaks.entry(input[1]).or_insert(0); *e += 1; } if peaks.len() >= peak_max { break; } } let mut operation = 0; for (_peak, count) in &peaks { if *count > 2 { operation += *count - 2; } } println!("{}", operation); }