結果
問題 | No.2226 Hello, Forgotten World! |
ユーザー |
|
提出日時 | 2023-02-24 21:42:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 935 bytes |
コンパイル時間 | 2,181 ms |
コンパイル使用メモリ | 178,640 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 05:15:27 |
合計ジャッジ時間 | 2,621 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h>using namespace std;string x = "helloworld";void solve() {int n;string s;cin >> n >> s;vector<string> can;for (int i = n - (int) x.size(); i >= 0; i--) {string t = s;bool ok = true;for (int j = 0; j < (int) x.size(); j++) {if (t[i + j] != '?' && t[i + j] != x[j]) {ok = false;break;} else {t[i + j] = x[j];}}if (ok) {for (auto&& c : t) {if (c == '?') {c = 'a';}}can.push_back(t);}}if (can.size()) {sort(can.begin(), can.end());cout << can[0] << endl;return;} else {cout << -1 << endl;return;}}int main() {int t;cin >> t;while (t--) {solve();}}