結果

問題 No.2226 Hello, Forgotten World!
ユーザー tree_splaytree_splay
提出日時 2023-02-24 21:36:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 3,814 ms
コンパイル使用メモリ 200,436 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 05:57:50
合計ジャッジ時間 2,825 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define INF 1234567890
#define ll long long

int T;
int N;
string s;
string H = "helloworld";

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	cin >> T;
	while(T--)
	{
		cin >> N >> s;
		string res = string(1, '~');
		for(int i=0; i+9<N; i++)
		{
			string t = s;

			int die = 0;
			for(int j=0; j<10; j++)
			{
				if (t[i+j] == '?')
					t[i+j] = H[j];
				else if (t[i+j] != H[j])
					die = 1;
			}
			if (die) continue;

			for(char &c : t)
				if (c == '?')
					c = 'a';

			res = min(res, t);
		}
		if (res == "~") res = "-1";
		cout << res << "\n";
	}
	return 0;
}
0