結果

問題 No.2226 Hello, Forgotten World!
ユーザー napiernapier
提出日時 2023-02-26 00:44:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,525 bytes
コンパイル時間 6,275 ms
コンパイル使用メモリ 316,144 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-10-11 19:24:10
合計ジャッジ時間 7,171 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,n-1,-1)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()
#define sort(x) sort(all(x))
#define rev(x) reverse(all(x))

const ll inf = (1LL<<60)+(1LL<<30);

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const string h = "helloworld";

void solve(int N, string S) {
    string T, ans;
    bool f;

    vi l;

    rep(i, N-9) {
        T = S.substr(i, 10);
        
        f = true;
        rep(j, 10) {
            f &= (T[j] == h[j] || T[j] == '?');
        }

        if (f) l.emplace_back(i);
    }

    if (!l.empty()) {
        int i = l[l.size()-1];
        ans += S.substr(0, i);
        ans += h;
        ans += S.substr(i+10);
        ans = regex_replace(ans, regex("\\?"), "a");
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}

int main() {
    int T;
    cin >> T;

    int N;
    string S;
    rep(i, T) {
        cin >> N >> S;
        solve(N, S);
    }
}
0