結果
問題 | No.2226 Hello, Forgotten World! |
ユーザー | hiro71687k |
提出日時 | 2023-02-24 21:49:05 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 1,753 bytes |
コンパイル時間 | 4,548 ms |
コンパイル使用メモリ | 267,232 KB |
実行使用メモリ | 4,352 KB |
最終ジャッジ日時 | 2023-10-11 06:07:27 |
合計ジャッジ時間 | 5,262 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,348 KB |
testcase_01 | AC | 14 ms
4,348 KB |
testcase_02 | AC | 5 ms
4,352 KB |
testcase_03 | AC | 4 ms
4,352 KB |
testcase_04 | AC | 2 ms
4,348 KB |
testcase_05 | AC | 5 ms
4,348 KB |
testcase_06 | AC | 3 ms
4,348 KB |
testcase_07 | AC | 4 ms
4,352 KB |
testcase_08 | AC | 2 ms
4,348 KB |
testcase_09 | AC | 3 ms
4,348 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using namespace std; using ll=int; using ld=double; ld pie=3.14159265359; ll mod=998244353; long long inf=100000000000000001; int main(){ ll t; cin >> t; string h="helloworld"; vector<string>ans; for (ll o = 0; o < t; o++) { ll n; cin >> n; string s; string ss; cin >> s; ss=s; bool ok=false; vector<string>a; for (ll i = s.size()-10; i>=0; i--) { ll now=0; for (ll j = i; j <i+10; j++) { if (s[j]=='?') { now+=1; }else{ if (s[j]==h[now]) { now+=1; } } } if (now>=10) { ok=true; ll now=0; for (ll j = i; j <i+10; j++) { if (s[j]=='?') { s[j]=h[now]; now+=1; }else{ now+=1; } } for (ll j = 0; j < s.size(); j++) { if (s[j]=='?') { s[j]='a'; } } a.push_back(s); s=ss; } } if (!ok) { ans.push_back("-1"); continue; } sort(a.begin(),a.end()); ans.push_back(a[0]); } for (ll i = 0; i < ans.size(); i++) { cout << ans[i] << endl; } }