結果

問題 No.2943 Sigma String of String Score Problem
ユーザー 沙耶花
提出日時 2024-10-18 22:01:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 295 ms / 3,000 ms
コード長 550 bytes
コンパイル時間 4,346 ms
コンパイル使用メモリ 253,724 KB
最終ジャッジ日時 2025-02-24 20:45:41
ジャッジサーバーID
(参考情報)
judge3 / judge8
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000000LL


int main(){
	
	string s,t;
	cin>>s>>t;
	int n = s.size(),m = t.size();
	vector<mint> dp(m+1,0);
	dp[0] = 1;
	rep(i,n){
		vector<mint> ndp(m+1,0);
		rep(j,m+1){
			ndp[j] += dp[j] * 2;
			if(j!=m && s[i]==t[j]) ndp[j+1] += dp[j];
		}
		swap(dp,ndp);
	}
	cout<<dp.back().val()<<endl;
	
	return 0;
}
0