結果

問題 No.2226 Hello, Forgotten World!
ユーザー shoshoshomshoshoshom
提出日時 2023-02-24 23:26:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 1,039 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 201,500 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-11 06:58:42
合計ジャッジ時間 2,903 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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