結果
| 問題 | No.706 多眼生物の調査 |
| コンテスト | |
| ユーザー |
cra77756176
|
| 提出日時 | 2022-12-19 19:38:19 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 540 bytes |
| 記録 | |
| コンパイル時間 | 10,434 ms |
| コンパイル使用メモリ | 141,612 KB |
| 最終ジャッジ日時 | 2026-05-12 17:24:50 |
| 合計ジャッジ時間 | 11,105 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
error: cannot explicitly dereference within an implicitly-borrowing pattern --> src/main.rs:16:22 | 16 | .filter(|(_, &n)| n == max) | ^ 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:16:18 | 16 | .filter(|(_, &n)| n == max) | ^^^^^^^ this non-reference pattern matches on a reference type `&_` help: match on the reference with a reference pattern to avoid implicitly borrowing | 16 | .filter(|&(_, &n)| n == max) | + error: could not compile `main` (bin "main") due to 1 previous error
ソースコード
use std::collections::HashMap;
fn main() {
let mut xx = String::new();
std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok();
let xx: Vec<&str> = xx.split_whitespace().skip(1).collect();
let mut count = HashMap::new();
for &x in &xx {
*count.entry(x.len() - 2).or_insert(0) += 1;
}
let max = *count.values().max().unwrap();
let answer = count
.iter()
.filter(|(_, &n)| n == max)
.map(|(&l, _)| l)
.max()
.unwrap();
println!("{answer}");
}
cra77756176