結果
| 問題 |
No.2226 Hello, Forgotten World!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-24 21:49:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,039 bytes |
| コンパイル時間 | 2,236 ms |
| コンパイル使用メモリ | 195,784 KB |
| 最終ジャッジ日時 | 2025-02-10 20:52:57 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const string key = "helloworld";
bool OK(string& s, int j) {
for (int i = 0; i < 10; i ++) {
if (s[i + j] != key[i] && s[i + j] != '?') {
return false;
}
}
for (int i = 0; i < 10; i ++) {
s[i + j] = key[i];
}
return true;
}
void solve() {
int N;
string s;
cin >> N >> s;
if (N < 10) {
cout << -1 << endl;
return;
}
for (int i = 0; i <= N - 10; i ++) {
if (s.substr(i, 10) == key) {
for (auto c : s) {
cout << (c == '?' ? 'a' : c);
}
cout << endl;
return;
}
}
for (int i = N - 10; i >= 0; i --) {
if (OK(s, i)) {
for (auto c : s) {
cout << (c == '?' ? 'a' : c);
}
cout << endl;
return;
}
}
cout << -1 << endl;
return;
}
int main () {
int N;
cin >> N;
for (int i = 0; i < N; i ++) {
solve();
}
}