結果
問題 | No.2943 Sigma String of String Score Problem |
ユーザー |
|
提出日時 | 2024-10-18 22:16:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 171 ms / 3,000 ms |
コード長 | 808 bytes |
コンパイル時間 | 2,173 ms |
コンパイル使用メモリ | 197,296 KB |
最終ジャッジ日時 | 2025-02-24 20:52:40 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/modint> using namespace std; using ll=long long; using mint=atcoder::modint998244353; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); string S,T; cin>>S>>T; int N=S.size(),M=T.size(); vector<mint>dp(M+1); dp[0]=1; for(int i=0;i<N;i++){ vector<mint>nxt=dp; for(int j=0;j<M;j++){ if(T[j]==S[i]){ nxt[j+1]+=dp[j]; } } swap(dp,nxt); } mint ans=dp[M]*mint(2).pow(N-M); cout<<ans.val()<<"\n"; }