結果
| 問題 |
No.2226 Hello, Forgotten World!
|
| コンテスト | |
| ユーザー |
hiro71687k
|
| 提出日時 | 2023-02-24 21:49:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 1,753 bytes |
| コンパイル時間 | 4,222 ms |
| コンパイル使用メモリ | 259,984 KB |
| 最終ジャッジ日時 | 2025-02-10 20:52:24 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=int;
using ld=double;
ld pie=3.14159265359;
ll mod=998244353;
long long inf=100000000000000001;
int main(){
ll t;
cin >> t;
string h="helloworld";
vector<string>ans;
for (ll o = 0; o < t; o++)
{
ll n;
cin >> n;
string s;
string ss;
cin >> s;
ss=s;
bool ok=false;
vector<string>a;
for (ll i = s.size()-10; i>=0; i--)
{
ll now=0;
for (ll j = i; j <i+10; j++)
{
if (s[j]=='?')
{
now+=1;
}else{
if (s[j]==h[now])
{
now+=1;
}
}
}
if (now>=10)
{
ok=true;
ll now=0;
for (ll j = i; j <i+10; j++)
{
if (s[j]=='?')
{
s[j]=h[now];
now+=1;
}else{
now+=1;
}
}
for (ll j = 0; j < s.size(); j++)
{
if (s[j]=='?')
{
s[j]='a';
}
}
a.push_back(s);
s=ss;
}
}
if (!ok)
{
ans.push_back("-1");
continue;
}
sort(a.begin(),a.end());
ans.push_back(a[0]);
}
for (ll i = 0; i < ans.size(); i++)
{
cout << ans[i] << endl;
}
}
hiro71687k