結果
| 問題 |
No.2226 Hello, Forgotten World!
|
| コンテスト | |
| ユーザー |
Manuel1024
|
| 提出日時 | 2023-12-27 21:27:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 810 bytes |
| コンパイル時間 | 1,048 ms |
| コンパイル使用メモリ | 77,404 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-27 15:34:44 |
| 合計ジャッジ時間 | 1,289 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;
void solve(int n, string s){
const string hello = "helloworld";
set<string> ans;
for(int i = n-10; i >= 0; i--){
bool isok = true;
for(int j = 0; j < 10; j++){
if(!(s[i+j] == '?' || s[i+j] == hello[j])) isok = false;
}
if(isok){
string t = s;
for(int j = 0; j < 10; j++) t[i+j] = hello[j];
for(int j = 0; j < n; j++){
if(t[j] == '?') t[j] = 'a';
}
ans.emplace(t);
}
}
cout << (ans.empty() ? "-1" : *ans.begin()) << '\n';
}
int main(){
int t; cin >> t;
while(t--){
int n; cin >> n;
string s; cin >> s;
solve(n, s);
}
return 0;
}
Manuel1024