結果
問題 | No.2226 Hello, Forgotten World! |
ユーザー | jiangly |
提出日時 | 2023-02-24 21:32:26 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 991 bytes |
コンパイル時間 | 1,976 ms |
コンパイル使用メモリ | 201,924 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 05:07:39 |
合計ジャッジ時間 | 2,511 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h> using i64 = long long; const std::string t = "helloworld"; void solve() { int n; std::cin >> n; std::string s; std::cin >> s; std::string ans; for (int i = 0; i + 10 <= n; i++) { bool ok = true; std::string a = s; for (int j = 0; j < 10; j++) { if (a[i + j] != '?' && a[i + j] != t[j]) { ok = false; } a[i + j] = t[j]; } if (!ok) { continue; } for (int j = 0; j < n; j++) { if (a[j] == '?') { a[j] = 'a'; } } if (ans.empty() || ans > a) { ans = a; } } if (ans.empty()) { ans = "-1"; } std::cout << ans << "\n"; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; std::cin >> t; while (t--) { solve(); } return 0; }