結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
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 <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);
		}

		int p=-1;
		REP(i,N-9){
			string y=s.substr(i,10);
			REP(j,v.size()){
				if(y==v[j]){
					p=i;
					f=true;
				}
			}
		}

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


		cout << -1 << endl;


	}

	return 0;
}
0