結果

問題 No.2226 Hello, Forgotten World!
ユーザー yansi819yansi819
提出日時 2024-04-10 12:39:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 923 bytes
コンパイル時間 4,570 ms
コンパイル使用メモリ 257,308 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 12:39:21
合計ジャッジ時間 4,434 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

void solve() {
  int N;
  string S, T, C = "helloworld", ans;
  cin >> N >> S;
  set<string> st;
  int pos = -1, j = 0;
  ans = string(N, 'z');
  for (int i = 0; i < N - 9; i++) {
    bool flag = true;
    for (int j = 0; j < 10; j++) {
      if (S[i + j] != C[j] && S[i + j] != '?') {
        flag = false;
        break;
      }
    }
    if (!flag) continue;
    T = "";
    for (int j = 0; j < N; j++) {
      if (j == i) {
        T += C;
        j += 9;
      } else if (S[j] == '?'){
        T += 'a';
      } else {
        T += S[j];
      }
    }
    if (ans > T) ans = T;
  }
  if (ans == string(N, 'z')) {
    cout << -1 << endl;
    return;
  }
  cout << ans << endl;
}

int main() {
  int T; cin >> T;
  while (T--) solve();
  return 0;
}
0