結果
問題 | No.2943 Sigma String of String Score Problem |
ユーザー |
![]() |
提出日時 | 2024-10-18 21:37:36 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 128 ms / 3,000 ms |
コード長 | 642 bytes |
コンパイル時間 | 1,306 ms |
コンパイル使用メモリ | 92,088 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-18 22:31:27 |
合計ジャッジ時間 | 3,714 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#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'; }