結果

問題 No.2226 Hello, Forgotten World!
ユーザー jianglyjiangly
提出日時 2023-02-24 21:32:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 991 bytes
コンパイル時間 3,420 ms
コンパイル使用メモリ 199,872 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-11 05:53:09
合計ジャッジ時間 2,901 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 8 ms
4,372 KB
testcase_02 AC 5 ms
4,368 KB
testcase_03 AC 5 ms
4,372 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 5 ms
4,368 KB
testcase_06 AC 3 ms
4,372 KB
testcase_07 AC 3 ms
4,368 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 3 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = long long;

const std::string t = "helloworld";

void solve() {
    int n;
    std::cin >> n;
    
    std::string s;
    std::cin >> s;
    
    std::string ans;
    
    for (int i = 0; i + 10 <= n; i++) {
        bool ok = true;
        std::string a = s;
        for (int j = 0; j < 10; j++) {
            if (a[i + j] != '?' && a[i + j] != t[j]) {
                ok = false;
            }
            a[i + j] = t[j];
        }
        if (!ok) {
            continue;
        }
        for (int j = 0; j < n; j++) {
            if (a[j] == '?') {
                a[j] = 'a';
            }
        }
        if (ans.empty() || ans > a) {
            ans = a;
        }
    }
    
    if (ans.empty()) {
        ans = "-1";
    }
    
    std::cout << ans << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int t;
    std::cin >> t;
    
    while (t--) {
        solve();
    }
    
    return 0;
}
0