結果

問題 No.2943 Sigma String of String Score Problem
ユーザー Today03
提出日時 2024-10-18 22:33:03
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 669 bytes
コンパイル時間 3,182 ms
コンパイル使用メモリ 252,984 KB
実行使用メモリ 397,952 KB
最終ジャッジ日時 2024-10-18 22:52:25
合計ジャッジ時間 9,915 ms
ジャッジサーバーID
(参考情報)
judge5 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 MLE * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9 + 10;
const ll INFL = 4e18;

#include <atcoder/modint>
using mint = atcoder::modint998244353;

int main() {
    string S, T;
    cin >> S >> T;
    int N = ssize(S), M = ssize(T);

    vector<vector<mint>> dp(N + 1, vector<mint>(M + 1));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= M; j++) {
            dp[i + 1][j] += dp[i][j];
            if (S[i] == T[j] && j < M) {
                dp[i + 1][j + 1] += dp[i][j];
            }
        }
    }

    mint ans = dp.back().back();
    ans *= mint(2).pow(N - M);
    cout << ans.val() << endl;
}
0