結果
問題 | No.2226 Hello, Forgotten World! |
ユーザー |
|
提出日時 | 2023-02-24 21:36:50 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 1,677 bytes |
コンパイル時間 | 12,079 ms |
コンパイル使用メモリ | 405,500 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 05:11:56 |
合計ジャッジ時間 | 12,916 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#![allow(dead_code, unused_imports, unused_macros, non_snake_case)]fn main() {let T = read_line().parse::<usize>().unwrap();let helloworld = "helloworld".chars().collect::<Vec<_>>();for _ in 0 .. T {let N = read_line().parse::<usize>().unwrap();let S = read_line().chars().collect::<Vec<_>>();let mut ans = None::<Vec<char>>;for i in 0 ..= N - 10 {if !(0 .. 10).all(|j| S[i + j] == helloworld[j] || S[i + j] == '?' ) {continue;}let mut s = S.clone();for j in 0 .. 10 {s[i + j] = helloworld[j];}for j in 0 .. N {if s[j] == '?' {s[j] = 'a';}}if let Some(a) = &ans {if a.cmp(&s).is_gt() {ans = Some(s);}} else {ans = Some(s);}}if let Some(a) = ans {println!("{}", a.into_iter().collect::<String>());} else {println!("-1");}}}type Int = i64;const MOD: Int = 1_000_000_007;const INF: Int = 1_000_000_000;const YESNO: [&'static str; 2] = ["Yes", "No"];fn read_line() -> String { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).ok(); buf.trim().to_string() }fn read_words() -> Vec<String> { read_line().split_whitespace().map(str::to_string).collect() }fn yes() { println!("{}", YESNO[0]); }fn no() { println!("{}", YESNO[1]); }fn yesno(c: bool) { println!("{}", if c { YESNO[0] } else { YESNO[1] }); }