結果

問題 No.2226 Hello, Forgotten World!
ユーザー Hydrogen332
提出日時 2024-09-28 01:31:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,021 bytes
コンパイル時間 2,367 ms
コンパイル使用メモリ 205,760 KB
最終ジャッジ日時 2025-02-24 13:50:03
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)s; i < (int)e; i++)

string key = "helloworld";

int main() {
    cin.tie(nullptr);
    
    int T;
    cin >> T;
    
    rep(testcase, 0, T) {
        int N;
        string S;
        cin >> N >> S;
        
        vector<string> res(0);
        rep(s, 0, N - 10 + 1) {
            bool flag = true;
            
            rep(i, 0, 10) {
                if (S[s + i] != '?' && S[s + i] != key[i]) flag = false;
            }
            
            if (flag) {
                string T = S;
                rep(i, 0, N) {
                    if (s <= i && i < s + 10) T[i] = key[i - s];
                    else if (T[i] == '?') T[i] = 'a';
                }
                res.push_back(T);
            }
        }
        if (res.size() == 0) {
            cout << -1 << '\n';
            continue;
        }
        
        sort(res.begin(), res.end());
        
        cout << res[0] << '\n';
    }
}
0