結果
問題 | No.2943 Sigma String of String Score Problem |
ユーザー |
|
提出日時 | 2024-10-18 22:53:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,787 ms / 3,000 ms |
コード長 | 1,095 bytes |
コンパイル時間 | 507 ms |
コンパイル使用メモリ | 82,604 KB |
実行使用メモリ | 79,288 KB |
最終ジャッジ日時 | 2024-10-18 22:56:47 |
合計ジャッジ時間 | 16,906 ms |
ジャッジサーバーID (参考情報) |
judge / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
def II() -> int : return int(input()) def MI() -> int : return map(int, input().split()) def TI() -> tuple[int] : return tuple(MI()) def LI() -> list[int] : return list(MI()) class fenwick_tree(): n=1 data=[0 for i in range(n)] def __init__(self,N): self.n=N self.data=[0 for i in range(N)] def add(self,p,x): assert 0<=p<self.n,"0<=p<n,p={0},n={1}".format(p,self.n) p+=1 while(p<=self.n): self.data[p-1]+=x p+=p& -p def sum(self,l,r): assert (0<=l and l<=r and r<=self.n),"0<=l<=r<=n,l={0},r={1},n={2}".format(l,r,self.n) return self.sum0(r)-self.sum0(l) def sum0(self,r): s=0 while(r>0): s+=self.data[r-1] r-=r&-r return s mod = 998244353 s,t = input().split() n = len(s) l = len(t) dp = [0]*(l+1) ndp = [0]*(l+1) dp[0] = 1 for i in range(n): for j in range(l+1): if j != l and s[i] == t[j]: ndp[j+1] += dp[j]%mod ndp[j] += dp[j]*2%mod dp = ndp[:] ndp = [0]*(l+1) # print(dp) print(dp[-1]%mod)