結果
| 問題 |
No.806 木を道に
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-13 23:08:30 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 934 bytes |
| コンパイル時間 | 12,450 ms |
| コンパイル使用メモリ | 399,528 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-19 13:36:08 |
| 合計ジャッジ時間 | 15,093 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 WA * 13 |
コンパイルメッセージ
warning: unnecessary parentheses around assigned value
--> src/main.rs:36:26
|
36 | operation += (*count - 2);
| ^ ^
|
= note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
|
36 - operation += (*count - 2);
36 + operation += *count - 2;
|
warning: unused variable: `peak`
--> src/main.rs:34:10
|
34 | for (peak, count) in &peaks {
| ^^^^ help: if this is intentional, prefix it with an underscore: `_peak`
|
= note: `#[warn(unused_variables)]` on by default
ソースコード
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);
}