結果

問題 No.2040 010-1 Deletion
ユーザー sotanishysotanishy
提出日時 2022-08-12 23:11:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 243 ms / 3,000 ms
コード長 780 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 76,928 KB
最終ジャッジ日時 2023-10-24 11:30:10
合計ジャッジ時間 7,012 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,536 KB
testcase_01 AC 35 ms
53,536 KB
testcase_02 AC 36 ms
53,536 KB
testcase_03 AC 54 ms
66,116 KB
testcase_04 AC 36 ms
53,536 KB
testcase_05 AC 36 ms
53,536 KB
testcase_06 AC 40 ms
53,536 KB
testcase_07 AC 36 ms
53,536 KB
testcase_08 AC 36 ms
53,536 KB
testcase_09 AC 36 ms
53,536 KB
testcase_10 AC 36 ms
53,536 KB
testcase_11 AC 213 ms
76,852 KB
testcase_12 AC 204 ms
76,928 KB
testcase_13 AC 210 ms
76,676 KB
testcase_14 AC 222 ms
76,668 KB
testcase_15 AC 188 ms
76,368 KB
testcase_16 AC 243 ms
76,616 KB
testcase_17 AC 175 ms
76,416 KB
testcase_18 AC 233 ms
76,848 KB
testcase_19 AC 92 ms
75,992 KB
testcase_20 AC 78 ms
76,040 KB
testcase_21 AC 127 ms
76,212 KB
testcase_22 AC 142 ms
76,380 KB
testcase_23 AC 184 ms
76,576 KB
testcase_24 AC 209 ms
76,812 KB
testcase_25 AC 166 ms
76,524 KB
testcase_26 AC 159 ms
76,400 KB
testcase_27 AC 180 ms
76,608 KB
testcase_28 AC 156 ms
76,408 KB
testcase_29 AC 182 ms
76,400 KB
testcase_30 AC 133 ms
76,380 KB
testcase_31 AC 194 ms
76,748 KB
testcase_32 AC 206 ms
76,784 KB
testcase_33 AC 202 ms
76,720 KB
testcase_34 AC 197 ms
76,744 KB
testcase_35 AC 197 ms
76,784 KB
testcase_36 AC 198 ms
76,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod = 998244353
N = int(input())
S = input().rstrip()
allone = [True] * (N+1)
for i in range(N)[::-1]:
    allone[i] = allone[i+1] and (S[i] in '1?')

ans = 0
if allone[0]:
    ans = 1

dp0 = [0] * (3*N+1)
dp1 = [0] * (3*N+1)
dp1[0] = 1

for i in range(N):
    ndp0 = [0] * (3*N+1)
    ndp1 = [0] * (3*N+1)
    if S[i] != '0':
        for j in range(-2*N, N+1):
            if j-2 >= -2*N:
                ndp1[j-2] = (ndp1[j-2] + dp0[j]) % mod
            ndp1[j] = (ndp1[j] + dp1[j]) % mod
    if S[i] != '1':
        for j in range(-2*N, N):
            ndp0[j+1] = (ndp0[j+1] + dp0[j] + dp1[j]) % mod
    dp0 = ndp0
    dp1 = ndp1

    if allone[i+1]:
        for i in range(-2*N, 1, 2):
            ans = (ans + dp0[i]) % mod
print(ans)
0