結果

問題 No.2943 Sigma String of String Score Problem
ユーザー LyricalMaestro
提出日時 2024-10-21 00:16:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,446 ms / 3,000 ms
コード長 486 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 82,520 KB
実行使用メモリ 76,556 KB
最終ジャッジ日時 2024-10-21 00:16:24
合計ジャッジ時間 11,354 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/2942


MOD = 998244353



def main():
    S, T = input().split()

    dp = [0] * (len(T) + 1)
    dp[0] = 1

    for s in S:
        new_dp = dp.copy()
        for t in range(len(T)):
            if s == T[t]:
                new_dp[t + 1] += dp[t]
                new_dp[t + 1] %= MOD
        dp = new_dp
    
    ans = dp[len(T)]

    ans *= pow(2, len(S) - len(T), MOD)
    ans %= MOD
    print(ans)










if __name__ == "__main__":
    main()
0