結果
問題 |
No.2226 Hello, Forgotten World!
|
ユーザー |
|
提出日時 | 2023-02-25 01:21:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 95 ms / 2,000 ms |
コード長 | 994 bytes |
コンパイル時間 | 1,978 ms |
コンパイル使用メモリ | 179,740 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 06:38:59 |
合計ジャッジ時間 | 2,912 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#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); } vector<string> u; REP(i,N-9){ string y=S.substr(i,10); REP(j,v.size()){ if(y==v[j]){ f=true; s=S; s.replace(i,10,x); REP(k,N) if(s[k]=='?') s[k]='a'; u.push_back(s); } } } if(f){ sort(u.begin(),u.end()); cout << u[0] << endl; continue; } cout << -1 << endl; } return 0; }