結果

問題 No.2226 Hello, Forgotten World!
ユーザー CoCo_Japan_pan
提出日時 2023-02-24 23:26:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,145 bytes
コンパイル時間 2,287 ms
コンパイル使用メモリ 194,440 KB
最終ジャッジ日時 2025-02-10 22:48:37
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

// 提出時にassertはオフ
#ifndef DEBUG
#ifndef NDEBUG
#define NDEBUG
#endif
#endif

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define ALL(x) (x).begin(), (x).end()
template <class T> using vec = vector<T>;

string solve(){
    int N;
    string S;
    cin >> N >> S;
    // 後ろからhelloworldの一致を試して、残りはaを詰め込む
    const string helloworld = "helloworld";
    const int size = helloworld.size();
    for(int i = N - size; i >= 0; i--){
        bool matched = true;
        for(int j = 0; j < size; j++){
            if(S[i + j] != '?' && S[i + j] != helloworld[j]) {
                matched = false;
                break;
            }
        }
        if(matched){
            for(int j = 0; j < size; j++) {
                S[i + j] = helloworld[j];
            }
            for(char &x : S){
                if(x == '?') x = 'a';
            }
            return S;
        }
    }
    return "-1";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    for(int i = 0; i < T; i++){
        cout << solve() << "\n";
    }
}
0