結果
問題 |
No.2943 Sigma String of String Score Problem
|
ユーザー |
|
提出日時 | 2024-10-24 00:15:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 128 ms / 3,000 ms |
コード長 | 585 bytes |
コンパイル時間 | 4,212 ms |
コンパイル使用メモリ | 253,312 KB |
最終ジャッジ日時 | 2025-02-24 22:35:36 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using mint = atcoder::modint998244353; int main(){ ios::sync_with_stdio(false); cin.tie(0); string s, t; cin >> s >> t; int n = s.size(), m = t.size(); vector<vector<int>> tb(26); for(int i = 0; i < m; i++) tb[t[i] - 'a'].emplace_back(i); for(int i = 0; i < 26; i++) reverse(tb[i].begin(), tb[i].end()); vector<mint> dp(m + 1); dp[0] = mint(2).pow(n - m); for(auto &&c : s){ for(auto &&p : tb[c - 'a']) dp[p + 1] += dp[p]; } cout << dp[m].val() << '\n'; }