結果
| 問題 |
No.806 木を道に
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-13 23:42:14 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 943 bytes |
| コンパイル時間 | 13,507 ms |
| コンパイル使用メモリ | 378,876 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 13:37:49 |
| 合計ジャッジ時間 | 14,446 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
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();
for _i in 0..peak_max-1 {
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;
}
}
let mut operation = 0;
for (_peak, count) in &peaks {
if *count > 2 {
operation += *count - 2;
}
}
println!("{}", operation);
}