結果

問題 No.2226 Hello, Forgotten World!
ユーザー piratapirata
提出日時 2023-02-25 00:14:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,220 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 66,712 KB
実行使用メモリ 4,496 KB
最終ジャッジ日時 2023-10-11 07:11:31
合計ジャッジ時間 1,612 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
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 <iostream>
#include <string>
using namespace std;

void solve(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    bool pos = false;
    string ans;
    for (int i = 0; i < N; i++) ans += 'z';

    string hw = "helloworld";
    for (int i = 0; i < N - 9; i++){
        string Sb = S.substr(i, 10);
        bool can = true;
        for (int j = 0; j < 10; j++){
            if (Sb[j] != hw[j] && Sb[j] != '?'){
                can = false;
            }
        }
        if (!can) continue;
        pos = true;
        string T;
        for (int j = 0; j < N; j++){
            if (S[j] == '?'){
                // 基準点から10以内であれば、helloworldにする
                if (j >= i && j < i + 10){
                    cout << j << " " << i << endl;
                    T += hw[j - i];
                }
                else{
                    T += 'a';
                }
            }
            else{
                T += S[j];
            }
        }
        if (T < ans){
            ans = T;
        }
    }
    if (pos) cout << ans << endl;
    else cout << -1 << endl;
    return;
}

int main(){
    int T;
    cin >> T;
    while(T--){
        solve();
    }
    return 0; 
}
0