結果
問題 | No.2226 Hello, Forgotten World! |
ユーザー |
|
提出日時 | 2023-02-24 21:32:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 991 bytes |
コンパイル時間 | 1,497 ms |
コンパイル使用メモリ | 193,412 KB |
最終ジャッジ日時 | 2025-02-10 20:34:10 |
ジャッジサーバーID (参考情報) |
judge3 / 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; }