結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 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 #

// 提出時に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を詰め込む
    string match = "helloworld";
    for(int i = N - 10; i >= 0; i--){
        bool matched = true;
        for(int j = 0; j < 10; j++){
            if(S[i + j] != '?' && S[i + j] != match[j]) {
                matched = false;
                continue;
            }
        }
        if(matched){
            for(int j = 0; j < 10; j++) {
                S[i + j] = match[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