結果
問題 |
No.2226 Hello, Forgotten World!
|
ユーザー |
![]() |
提出日時 | 2025-09-24 00:37:18 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 22 ms / 2,000 ms |
コード長 | 761 bytes |
コンパイル時間 | 6,677 ms |
コンパイル使用メモリ | 278,532 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-24 00:37:30 |
合計ジャッジ時間 | 3,716 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; inline void solve() { int n; string s; cin >> n >> s; string ans = "-1"; for (int i = n - 10; i >= 0; --i) { string t = s.substr(i, 10); bool match = true; rep(j, 10) { if (t[j] == '?' || t[j] == "helloworld"[j]) continue; match = false; break; } if (match) { string u = s; rep(j, 10) u[i + j] = "helloworld"[j]; rep(j, n) if (u[j] == '?') u[j] = 'a'; if (ans == "-1" || u < ans) ans = u; } } cout << ans << '\n'; } int main() { cin.tie(nullptr)->sync_with_stdio(false); int t; cin >> t; while (t--) solve(); return 0; }