結果

問題 No.2226 Hello, Forgotten World!
ユーザー Carpenters-Cat
提出日時 2023-02-24 21:47:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 807 bytes
コンパイル時間 1,700 ms
コンパイル使用メモリ 193,208 KB
最終ジャッジ日時 2025-02-10 20:49:11
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 9
権限があれば一括ダウンロードができます

ソースコード

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