結果
| 問題 |
No.2226 Hello, Forgotten World!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-25 17:40:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 2,000 ms |
| コード長 | 828 bytes |
| コンパイル時間 | 2,424 ms |
| コンパイル使用メモリ | 204,900 KB |
| 最終ジャッジ日時 | 2025-02-10 23:23:29 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<int(n);i++)
const int MOD = 998244353;
int main(){
string he="helloworld";
int t;
cin>>t;
rep(Ti,t){
int n;
cin>>n;
string s;
cin>>s;
vector<string> ans;
for(int i=n-he.size();i>=0;i--){
int flg=0;
for(int j=0;j<he.size();j++){
if(s.at(i+j)=='?') continue;
if(s.at(i+j)!=he.at(j)){
flg=1;
break;
}
}
if(flg) continue;
string ls=s;
for(int j=0;j<he.size();j++){
ls.at(i+j)=he.at(j);
}
for(int j=0;j<n;j++){
if(ls.at(j)=='?') ls.at(j)='a';
}
ans.push_back(ls);
}
sort(ans.begin(),ans.end());
if(ans.size()==0) cout<<"-1"<<endl;
else cout<<ans.at(0)<<endl;
}
}