結果
問題 | No.2226 Hello, Forgotten World! |
ユーザー |
|
提出日時 | 2023-02-25 00:15:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 1,223 bytes |
コンパイル時間 | 626 ms |
コンパイル使用メモリ | 67,504 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 06:21:19 |
合計ジャッジ時間 | 1,181 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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] == '?'){// 基準点から10以内であれば、helloworldにするif (j >= i && j < i + 10){// cout << j << " " << i << endl;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;}