結果
問題 |
No.2226 Hello, Forgotten World!
|
ユーザー |
|
提出日時 | 2024-04-10 12:39:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 923 bytes |
コンパイル時間 | 4,525 ms |
コンパイル使用メモリ | 253,636 KB |
最終ジャッジ日時 | 2025-02-20 23:40:50 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using mint = modint998244353; void solve() { int N; string S, T, C = "helloworld", ans; cin >> N >> S; set<string> st; int pos = -1, j = 0; ans = string(N, 'z'); for (int i = 0; i < N - 9; i++) { bool flag = true; for (int j = 0; j < 10; j++) { if (S[i + j] != C[j] && S[i + j] != '?') { flag = false; break; } } if (!flag) continue; T = ""; for (int j = 0; j < N; j++) { if (j == i) { T += C; j += 9; } else if (S[j] == '?'){ T += 'a'; } else { T += S[j]; } } if (ans > T) ans = T; } if (ans == string(N, 'z')) { cout << -1 << endl; return; } cout << ans << endl; } int main() { int T; cin >> T; while (T--) solve(); return 0; }