結果
| 問題 | No.1905 PURE PHRASE |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-10 18:08:47 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 932 bytes |
| 記録 | |
| コンパイル時間 | 243 ms |
| コンパイル使用メモリ | 149,832 KB |
| 最終ジャッジ日時 | 2026-07-29 02:22:08 |
| 合計ジャッジ時間 | 1,367 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
error: cannot explicitly dereference within an implicitly-borrowing pattern --> src/main.rs:28:57 | 28 | let idx = sounds.iter().enumerate().min_by_key(|(_, &v)| v).unwrap().0; | ^ 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:28:53 | 28 | let idx = sounds.iter().enumerate().min_by_key(|(_, &v)| v).unwrap().0; | ^^^^^^^ this non-reference pattern matches on a reference type `&_` help: match on the reference with a reference pattern to avoid implicitly borrowing | 28 | let idx = sounds.iter().enumerate().min_by_key(|&(_, &v)| v).unwrap().0; | + error: could not compile `main` (bin "main") due to 1 previous error
ソースコード
const C4: f64 = 261.6;
const D4: f64 = 294.3;
const E4: f64 = 327.0;
const F4: f64 = 348.8;
const G4: f64 = 392.4;
const A4: f64 = 436.0;
const B4: f64 = 490.5;
fn main() {
let mut n = String::new();
std::io::stdin().read_line(&mut n).ok();
let n: usize = n.trim().parse().unwrap();
let mut a = String::new();
std::io::stdin().read_line(&mut a).ok();
let a: Vec<isize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
let mut sounds = vec![0isize; 7];
let hz = vec![C4, D4, E4, F4, G4, A4, B4];
let words = vec!["C4", "D4", "E4", "F4", "G4", "A4", "B4"];
for j in 0..hz.len() {
let period = (n as f64 / hz[j]).floor() as usize;
for i in 0..n/2 {
sounds[j] += (a[i] - a[i + period]).abs();
}
}
eprintln!("{:?}", sounds);
let idx = sounds.iter().enumerate().min_by_key(|(_, &v)| v).unwrap().0;
println!("{}", words[idx]);
}