結果
問題 | No.2226 Hello, Forgotten World! |
ユーザー | Manuel1024 |
提出日時 | 2023-12-27 21:27:31 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 810 bytes |
コンパイル時間 | 768 ms |
コンパイル使用メモリ | 76,564 KB |
実行使用メモリ | 6,676 KB |
最終ジャッジ日時 | 2023-12-27 21:27:33 |
合計ジャッジ時間 | 1,472 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,676 KB |
testcase_01 | AC | 13 ms
6,676 KB |
testcase_02 | AC | 5 ms
6,676 KB |
testcase_03 | AC | 5 ms
6,676 KB |
testcase_04 | AC | 3 ms
6,676 KB |
testcase_05 | AC | 5 ms
6,676 KB |
testcase_06 | AC | 3 ms
6,676 KB |
testcase_07 | AC | 4 ms
6,676 KB |
testcase_08 | AC | 2 ms
6,676 KB |
testcase_09 | AC | 4 ms
6,676 KB |
ソースコード
#include <iostream> #include <vector> #include <string> #include <set> using namespace std; void solve(int n, string s){ const string hello = "helloworld"; set<string> ans; for(int i = n-10; i >= 0; i--){ bool isok = true; for(int j = 0; j < 10; j++){ if(!(s[i+j] == '?' || s[i+j] == hello[j])) isok = false; } if(isok){ string t = s; for(int j = 0; j < 10; j++) t[i+j] = hello[j]; for(int j = 0; j < n; j++){ if(t[j] == '?') t[j] = 'a'; } ans.emplace(t); } } cout << (ans.empty() ? "-1" : *ans.begin()) << '\n'; } int main(){ int t; cin >> t; while(t--){ int n; cin >> n; string s; cin >> s; solve(n, s); } return 0; }