結果

問題 No.2541 Divide 01 String
ユーザー ShirotsumeShirotsume
提出日時 2023-08-30 14:04:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 326 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 93,772 KB
最終ジャッジ日時 2023-08-30 14:04:06
合計ジャッジ時間 4,834 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,332 KB
testcase_01 AC 74 ms
71,356 KB
testcase_02 AC 75 ms
71,400 KB
testcase_03 AC 87 ms
76,492 KB
testcase_04 AC 90 ms
77,192 KB
testcase_05 AC 118 ms
93,568 KB
testcase_06 AC 89 ms
76,836 KB
testcase_07 AC 117 ms
93,600 KB
testcase_08 AC 121 ms
93,644 KB
testcase_09 AC 119 ms
93,772 KB
testcase_10 AC 118 ms
93,572 KB
testcase_11 AC 117 ms
93,692 KB
testcase_12 AC 116 ms
93,452 KB
testcase_13 AC 73 ms
71,016 KB
testcase_14 AC 75 ms
71,116 KB
testcase_15 AC 76 ms
71,352 KB
testcase_16 AC 74 ms
71,296 KB
testcase_17 AC 76 ms
71,268 KB
testcase_18 AC 88 ms
77,408 KB
testcase_19 AC 87 ms
77,216 KB
testcase_20 AC 87 ms
77,292 KB
testcase_21 AC 85 ms
77,060 KB
testcase_22 AC 86 ms
76,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
mod = 998244353
dp = [[0] * 2 for _ in range(n + 1)]
dp[0][0] = 1

for i in range(n):
    if s[i] == '0':
        dp[i + 1][0] += dp[i][0] + dp[i][1]
    else:
        dp[i + 1][1] += dp[i][0] + dp[i][1]
    dp[i + 1][1] += dp[i][1]
    dp[i + 1][0] %= mod
    dp[i + 1][1] %= mod

print(dp[n][1])
0