結果

問題 No.2943 Sigma String of String Score Problem
コンテスト
ユーザー hitonanode
提出日時 2024-10-18 21:37:36
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 228 ms / 3,000 ms
コード長 642 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,780 ms
コンパイル使用メモリ 168,004 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2026-05-05 15:09:01
合計ジャッジ時間 9,702 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

constexpr int md = mint::mod();

int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);

    string S, T;
    cin >> S >> T;

    const int n = T.size();

    vector<int> dp(n + 1);
    dp[0] = 1;
    for (auto c : S) {
        for (int i = n - 1; i >= 0; --i) {
            if (T[i] == c) {
                dp[i + 1] += dp[i];
                if (dp[i + 1] >= md) dp[i + 1] -= md;
            }
        }
    }

    cout << (mint(2).pow(S.size() - T.size()) * dp.back()).val() << '\n';
}
0