結果
| 問題 |
No.2226 Hello, Forgotten World!
|
| コンテスト | |
| ユーザー |
sakasu1
|
| 提出日時 | 2023-03-26 21:39:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 763 bytes |
| コンパイル時間 | 1,953 ms |
| コンパイル使用メモリ | 204,096 KB |
| 最終ジャッジ日時 | 2025-02-11 18:16:49 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
int i,j,t;
cin >> t;
while(t--){
vector<string> ans;
int n;
string s,t="helloworld",s1;
cin >> n >> s;
s1=s;
for(i=n-10;i>=0;i--){
bool flag=true;
for(j=i;j<i+10;j++){
if(!(s[j]==t[j-i] || s[j]=='?')) flag=false;
}
if(flag==false) continue;
for(j=i;j<i+10;j++){
if(s[j]=='?') s[j]=t[j-i];
}
for(j=0;j<i;j++){
if(s[j]=='?') s[j]='a';
}
for(j=i+10;j<n;j++){
if(s[j]=='?') s[j]='a';
}
ans.push_back(s);
s=s1;
}
sort(ans.begin(),ans.end());
if(ans.size()==0) cout << -1 << endl;
else cout << ans[0] << endl;
}
}
sakasu1