結果

問題 No.2226 Hello, Forgotten World!
ユーザー daiotadaiota
提出日時 2023-02-25 01:21:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 994 bytes
コンパイル時間 1,873 ms
コンパイル使用メモリ 177,272 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 07:33:57
合計ジャッジ時間 3,146 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<int(n);i++)


int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	int i,j,k;

	int T;
	cin >> T;
	REP(tc,T){

		int N;
		string S;
		cin >> N >> S;

		string x="helloworld",s=S;
		bool f=false;
		REP(i,N-9){
			string y=s.substr(i,10);
			if(x==y){
				f=true;
				break;
			}
		}

		if(f){
			REP(i,N) if(s[i]=='?') s[i]='a';
			cout << s << endl;
			continue;
		}

		vector<string> v;
		for(i=0;i<(1<<10);i++){
			string t=x;
			for(j=0;j<10;j++){
				if(i&(1<<j)) t[j]='?';
			}
			v.push_back(t);
		}

		vector<string> u;
		REP(i,N-9){
			string y=S.substr(i,10);
			REP(j,v.size()){
				if(y==v[j]){
					f=true;
					s=S;
					s.replace(i,10,x);
					REP(k,N) if(s[k]=='?') s[k]='a';
					u.push_back(s);
				}
			}
		}

		if(f){
			sort(u.begin(),u.end());
			cout << u[0] << endl;
			continue;
		}


		cout << -1 << endl;


	}

	return 0;
}
0