結果

問題 No.2226 Hello, Forgotten World!
ユーザー zezero
提出日時 2023-02-24 22:44:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,149 bytes
コンパイル時間 3,203 ms
コンパイル使用メモリ 160,504 KB
最終ジャッジ日時 2025-02-10 21:56:05
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
const ll mod = 998244353;
void slove(){
int n;
cin >> n;
string s;
cin >> s;
string ans = "{}";
string h = "helloworld";
for (int i = n-10; i >= 0;i--){
string t = s;
bool can = true;
for (int j = i; j < i+10;j++){
if (t[j] == h[j-i]) continue;
else if (t[j] == '?'){
t[j] = h[j-i];
continue;
}
else{
//cout << "i:" << i << " j:" << j << endl;
can = false;
break;
}
}
if (can){
for (int j = 0; j < n;j++){
if (t[j] == '?') t[j] = 'a';
}
//cout << "i:" << i << endl;
//cout << t << endl;
ans = min(ans,t);
}
}
if (ans == "{}"){
cout << -1 << endl;
}
else{
cout << ans << endl;
}
}
int main(){
int t;
cin >> t;
while(t--){
slove();
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0