結果

問題 No.2226 Hello, Forgotten World!
ユーザー shoshoshom
提出日時 2023-02-24 23:26:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,039 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 195,420 KB
最終ジャッジ日時 2025-02-10 22:48:31
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cctype>
#ifndef SHO_LOCAL
#include <bits/stdc++.h>
#define debug(...) ;
#else
#include "debug.h"
#endif
#define all(x) (x).begin(), (x).end()
#define lb(x, a) lower_bound(all(x), (a)) - (x).begin()
typedef long long ll;
using namespace std;

int main() {
  iostream::sync_with_stdio(0), cin.tie(0);

  int T;
  cin >> T;
  int n;
  string s;
  const string S = "helloworld";
  const string inf = string(1000, 'z');
  int m = (int)S.size();
  while (T--) {
    cin >> n >> s;
    string ans = inf;
    for (int i = 0; i + 10 <= n; i++) {
      bool ok = true;
      string now = "";
      for (int j = 0; ok && j < n; j++) {
        if (j >= i && j < i + 10) {
          ok &= s[j] == '?' || s[j] == S[j - i];
          now += S[j - i];
        } else {
          if (s[j] == '?') {
            now += 'a';
          } else {
            now += s[j];
          }
        }
      }
      if (ok) {
        ans = min(ans, now);
      }
    }
    if (ans == inf) {
      ans = "-1";
    }
    cout << ans << '\n';
  }

  return 0;
}
0