結果
| 問題 | No.182 新規性の虜 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-16 15:05:51 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 334 bytes |
| 記録 | |
| コンパイル時間 | 354 ms |
| コンパイル使用メモリ | 144,932 KB |
| 最終ジャッジ日時 | 2026-05-27 11:50:16 |
| 合計ジャッジ時間 | 2,012 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
error: cannot explicitly dereference within an implicitly-borrowing pattern
--> src/main.rs:11:38
|
11 | println!("{}", h.iter().filter(|(_, &v)| v == 1).count());
| ^ reference pattern not allowed when implicitly borrowing
|
= note: for more information, see <https://doc.rust-lang.org/reference/patterns.html#binding-modes>
note: matching on a reference type with a non-reference pattern implicitly borrows the contents
--> src/main.rs:11:34
|
11 | println!("{}", h.iter().filter(|(_, &v)| v == 1).count());
| ^^^^^^^ this non-reference pattern matches on a reference type `&_`
help: match on the reference with a reference pattern to avoid implicitly borrowing
|
11 | println!("{}", h.iter().filter(|&(_, &v)| v == 1).count());
| +
error: could not compile `main` (bin "main") due to 1 previous error
ソースコード
use std::{collections::HashMap, io::Read};
fn main() {
let mut s = String::new();
std::io::stdin().read_to_string(&mut s).ok();
let mut h = HashMap::new();
s.split_whitespace()
.skip(1)
.flat_map(str::parse::<u32>)
.for_each(|a| *h.entry(a).or_insert(0) += 1);
println!("{}", h.iter().filter(|(_, &v)| v == 1).count());
}