結果

問題 No.2226 Hello, Forgotten World!
ユーザー 唐揚げが壊わ唐揚げが壊わ
提出日時 2023-02-25 03:27:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 1,442 bytes
コンパイル時間 2,336 ms
コンパイル使用メモリ 208,660 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 08:17:13
合計ジャッジ時間 3,457 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
#define lln \
  ll n;     \
  cin >> n;
#define REP(i, n) for (long long i = 0; i < n; i++)
#define REPIN(v, n) \
  for (long long i = 0; i < n; i++) cin >> v[i];
ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main() {
  ll T;
  cin >> T;
  string hello = "helloworld";
  REP(t, T) {
    ll n, cnt;
    string s;
    bool J;
    cin >> n >> s;
    cnt = -1;
    vs v = {};
    REP(i, n) {
      if (s[i] == hello[0] || s[i] == '?') {
        J = true;
        REP(j, hello.size()) {
          if (!(i + j < n)) {
            J = false;
            break;
          }
          if (s[i + j] == hello[j] || s[i + j] == '?') {
          } else {
            J = false;
          }
        }
        if (J) {
          string S = s;
          REP(k, n) {
            if (i <= k && k < i + hello.size()) {
              S[k] = hello[k - i];
            } else {
              S[k] = ((s[k] == '?') ? 'a' : s[k]);
            }
          }
          v.push_back(S);
        }
      }
    }
    if (v.empty()) {
      cout << -1 << endl;
    } else {
      sort(v.begin(), v.end());
      cout << v[0] << endl;
    }
  }
  return 0;
}
0