結果
| 問題 | No.52 よくある文字列の問題 |
| コンテスト | |
| ユーザー |
cra77756176
|
| 提出日時 | 2022-12-13 19:46:26 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,167 bytes |
| 記録 | |
| コンパイル時間 | 764 ms |
| コンパイル使用メモリ | 138,696 KB |
| 最終ジャッジ日時 | 2026-05-07 22:11:37 |
| 合計ジャッジ時間 | 1,776 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
error: expected identifier, found reserved keyword `gen`
--> src/main.rs:15:19
|
15 | for (rem, gen) in &strings {
| ^^^ expected identifier, found reserved keyword
|
help: escape `gen` to use it as an identifier
|
15 | for (rem, r#gen) in &strings {
| ++
error: expected `{`, found `}`
--> src/main.rs:31:9
|
31 | }
| ^ expected `{`
error[E0658]: gen blocks are experimental
--> src/main.rs:16:22
|
16 | for s in gen {
| ^^^
|
= note: see issue #117078 <https://github.com/rust-lang/rust/issues/117078> for more information
For more information about this error, try `rustc --explain E0658`.
error: could not compile `main` (bin "main") due to 3 previous errors
ソースコード
use std::collections::{HashMap, HashSet};
fn main() {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
let s: Vec<char> = s.trim().chars().collect();
let mut strings = HashMap::new();
strings.insert(s.clone(), HashSet::<Vec<char>>::new());
strings.entry(s).or_default().insert(vec![]);
while !strings.keys().next().unwrap().is_empty() {
let mut new_strings: HashMap<Vec<char>, HashSet<Vec<char>>> = HashMap::new();
for (rem, gen) in &strings {
for s in gen {
let mut new_s_left = s.clone();
new_s_left.push(rem[0]);
new_strings
.entry(rem[1..].to_vec())
.or_default()
.insert(new_s_left);
let mut new_s_right = s.clone();
new_s_right.push(rem[rem.len() - 1]);
new_strings
.entry(rem[..rem.len() - 1].to_vec())
.or_default()
.insert(new_s_right);
}
}
strings = new_strings;
}
println!("{}", strings.values().next().unwrap().len());
}
cra77756176