結果

問題 No.2231 Surprising Flash!
ユーザー KumaTachiRenKumaTachiRen
提出日時 2023-10-06 12:35:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,749 bytes
コンパイル時間 4,802 ms
コンパイル使用メモリ 268,396 KB
実行使用メモリ 36,132 KB
最終ジャッジ日時 2023-10-06 12:35:24
合計ジャッジ時間 17,715 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 65 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 5 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 238 ms
32,284 KB
testcase_12 AC 245 ms
36,084 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 238 ms
32,312 KB
testcase_16 AC 240 ms
4,960 KB
testcase_17 AC 259 ms
6,608 KB
testcase_18 AC 233 ms
30,000 KB
testcase_19 AC 234 ms
29,992 KB
testcase_20 AC 234 ms
30,004 KB
testcase_21 AC 230 ms
30,060 KB
testcase_22 AC 232 ms
30,004 KB
testcase_23 AC 232 ms
29,996 KB
testcase_24 AC 232 ms
29,980 KB
testcase_25 AC 232 ms
30,008 KB
testcase_26 AC 234 ms
30,068 KB
testcase_27 AC 232 ms
30,040 KB
testcase_28 AC 234 ms
30,052 KB
testcase_29 AC 237 ms
32,240 KB
testcase_30 AC 237 ms
32,300 KB
testcase_31 AC 237 ms
32,248 KB
testcase_32 AC 236 ms
32,236 KB
testcase_33 AC 238 ms
32,308 KB
testcase_34 AC 237 ms
32,220 KB
testcase_35 AC 235 ms
32,300 KB
testcase_36 AC 238 ms
32,228 KB
testcase_37 AC 237 ms
32,292 KB
testcase_38 AC 237 ms
32,292 KB
testcase_39 AC 111 ms
6,444 KB
testcase_40 AC 74 ms
6,380 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;
using namespace atcoder;

struct Fast {
  Fast() {
    std::cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(10);
  }
} fast;

#define all(a) (a).begin(), (a).end()
#define contains(a, x) ((a).find(x) != (a).end())
#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (a); i--)
#define writejoin(s, a) rep(_i, 0, (a).size()) cout << (a)[_i] << (_i + 1 < (int)(a).size() ? s : "\n");
#define YN(b) cout << ((b) ? "YES" : "NO") << "\n";
#define Yn(b) cout << ((b) ? "Yes" : "No") << "\n";
#define yn(b) cout << ((b) ? "yes" : "no") << "\n";

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using mint = modint998244353;
using vm = vector<mint>;

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    string s1, s2;
    cin >> s1 >> s2;

    vm a1(n), a2(n), a3(n);
    rep(i, 0, n) {
      int c = s1[i] == '?' ? 0 : s1[i] - 'a' + 1;
      a1[i] = c;
      a2[i] = c * c;
      a3[i] = c * c * c;
    }
    vm b0(m, 1), b1(m), b2(m);
    rep(i, 0, m) {
      int c = s2[m - 1 - i] - 'a' + 1;
      b0[i] = 1;
      b1[i] = c;
      b2[i] = c * c;
    }

    auto c1 = convolution(a1, b2);
    auto c2 = convolution(a2, b1);
    auto c3 = convolution(a3, b0);
    vm c0(n + m - 1);
    rep(i, 0, n + m - 1) c0[i] = c1[i] - 2 * c2[i] + c3[i];
    int ans = -1;
    rep(k, 0, n - m + 1) {
      if (c0[m - 1 + k] == 0) ans = k;
    }
    if (ans == -1) {
      cout << -1 << "\n";
    } else {
      rep(i, 0, m) s1[i + ans] = s2[i];
      rep(i, 0, n) cout << (s1[i] == '?' ? 'a' : s1[i]);
      cout << "\n";
    }
  }
}
0