結果
問題 | No.2943 Sigma String of String Score Problem |
ユーザー |
![]() |
提出日時 | 2024-10-18 23:00:37 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 260 ms / 3,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 3,541 ms |
コンパイル使用メモリ | 251,300 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-18 23:01:33 |
合計ジャッジ時間 | 5,422 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#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<mint> dp(M + 1), ndp = dp; dp[0] = 1; for (int i = 0; i < N; i++) { for (int j = 0; j <= M; j++) ndp[j] = 0; for (int j = 0; j <= M; j++) { ndp[j] += dp[j]; if (S[i] == T[j] && j < M) { ndp[j + 1] += dp[j]; } } dp.swap(ndp); } mint ans = dp.back(); ans *= mint(2).pow(N - M); cout << ans.val() << endl; }