結果
問題 | No.2226 Hello, Forgotten World! |
ユーザー |
👑 ![]() |
提出日時 | 2022-12-01 01:57:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 1,092 bytes |
コンパイル時間 | 2,285 ms |
コンパイル使用メモリ | 68,876 KB |
最終ジャッジ日時 | 2025-02-09 03:00:18 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <iostream>#include <string>using namespace std;void solve(){int N;cin >> N;string S;cin >> S;bool pos = false;string ans;for (int i = 0; i < N; i++) ans += 'z';string hw = "helloworld";for (int i = 0; i < N - 9; i++){string Sb = S.substr(i, 10);bool can = true;for (int j = 0; j < 10; j++){if (Sb[j] != hw[j] && Sb[j] != '?'){can = false;}}if (!can) continue;pos = true;string T;for (int j = 0; j < N; j++){if (S[j] == '?'){if (j >= i && j < i + 10){T += hw[j - i];}else{T += 'a';}}else{T += S[j];}}if (T < ans){ans = T;}}if (pos) cout << ans << endl;else cout << -1 << endl;return;}int main(){int T;cin >> T;while(T--){solve();}return 0;}