結果

問題 No.2226 Hello, Forgotten World!
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-02-24 21:47:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 807 bytes
コンパイル時間 1,904 ms
コンパイル使用メモリ 199,984 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 06:04:52
合計ジャッジ時間 2,570 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const string key = "helloworld";
bool OK(string& s, int j) {
    for (int i = 0; i < 10; i ++) {
        if (s[i + j] != key[i] && s[i + j] != '?') {
            return false;
        }
    }
    for (int i = 0; i < 10; i ++) {
        s[i + j] = key[i];
    }
    return true;
}
void solve() {
    int N;
    string s;
    cin >> N >> s;
    if (N < 10) {
        cout << -1 << endl;
        return;
    }
    for (int i = N - 10; i >= 0; i --) {
        if (OK(s, i)) {
            for (auto c : s) {
                cout << (c == '?' ? 'a' : c);
            }
            cout << endl;
            return;
        }
    }
    cout << -1 << endl;
    return;
}
int main () {
    int N;
    cin >> N;
    for (int i = 0; i < N; i ++) {
        solve();
    }
}
0