結果
| 問題 |
No.2226 Hello, Forgotten World!
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2023-02-24 23:11:19 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 1,152 bytes |
| コンパイル時間 | 824 ms |
| コンパイル使用メモリ | 81,484 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 06:03:13 |
| 合計ジャッジ時間 | 1,313 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <iostream>
#include <string>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const string target = "helloworld";
string solve(string S) {
const int N = S.size();
string candidate;
candidate += (char)('z' + 1);
IREP(i, N - int(target.size()) + 1) {
bool good = true;
REP(j, target.size()) {
if (S.at(i + j) == '?') continue;
if (S.at(i + j) != target.at(j)) good = false;
}
if (good) {
string T = S;
REP(j, target.size()) T.at(i + j) = target.at(j);
for (auto &c : T)
if (c == '?') c = 'a';
candidate = min(candidate, T);
}
}
if (candidate.size() <= 1) return "-1";
return candidate;
}
int main() {
cin.tie(nullptr), ios::sync_with_stdio(false);
int T;
cin >> T;
while (T--) {
int N;
string S;
cin >> N >> S;
cout << solve(S) << '\n';
}
}
hitonanode