結果

問題 No.2541 Divide 01 String
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-11-25 10:23:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 255 bytes
コンパイル時間 400 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 89,108 KB
最終ジャッジ日時 2023-11-25 10:23:09
合計ジャッジ時間 2,575 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 48 ms
67,352 KB
testcase_04 AC 57 ms
78,500 KB
testcase_05 AC 66 ms
87,372 KB
testcase_06 AC 51 ms
75,600 KB
testcase_07 AC 70 ms
87,484 KB
testcase_08 AC 71 ms
88,984 KB
testcase_09 AC 68 ms
88,976 KB
testcase_10 AC 67 ms
88,964 KB
testcase_11 AC 71 ms
89,108 KB
testcase_12 AC 72 ms
89,108 KB
testcase_13 AC 36 ms
53,460 KB
testcase_14 AC 35 ms
53,460 KB
testcase_15 AC 35 ms
53,460 KB
testcase_16 AC 36 ms
53,460 KB
testcase_17 AC 35 ms
53,460 KB
testcase_18 AC 60 ms
83,100 KB
testcase_19 AC 61 ms
83,096 KB
testcase_20 AC 61 ms
83,092 KB
testcase_21 AC 51 ms
78,188 KB
testcase_22 AC 50 ms
78,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = list(map(int,input()))
mod = 998244353

dp = [1,0]

for s in S:
    ndp = [0,0]
    if s:
        ndp[1] = (dp[1]*2 + dp[0]) % mod
    else:
        ndp[0] = (dp[0] + dp[1]) % mod
        ndp[1] = dp[1]
    dp = ndp

print(dp[1])
    
0