結果

問題 No.2226 Hello, Forgotten World!
ユーザー みここみここ
提出日時 2023-02-24 21:34:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,106 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 71,244 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 05:55:23
合計ジャッジ時間 1,358 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;

string hello = "helloworld";

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        string s;
        cin >> n >> s;
        string ans = "{";
        for (int i = 0; i < n - 9; i++)
        {
            bool f = true;
            for (int j = 0; j < 10; j++)
            {
                if (s[i + j] != '?' && s[i + j] != hello[j])
                {
                    f = false;
                    break;
                }
            }
            if (f)
            {
                string t = s;
                for (int j = 0; j < n; j++)
                {
                    if (t[j] == '?')
                    {
                        t[j] = 'a';
                    }
                }
                for (int j = 0; j < 10; j++)
                {
                    t[i + j] = hello[j];
                }
                ans = min(ans, t);
            }
        }
        if (ans == "{")
        {
            cout << -1 << endl;
        }
        else
        {
            cout << ans << endl;
        }
    }
}
0