結果

問題 No.2040 010-1 Deletion
ユーザー googol_S0googol_S0
提出日時 2022-08-12 22:01:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 324 ms / 3,000 ms
コード長 751 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 81,656 KB
実行使用メモリ 147,368 KB
最終ジャッジ日時 2023-10-24 10:02:23
合計ジャッジ時間 9,411 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,400 KB
testcase_01 AC 37 ms
53,400 KB
testcase_02 AC 37 ms
53,400 KB
testcase_03 AC 51 ms
63,772 KB
testcase_04 AC 42 ms
53,400 KB
testcase_05 AC 38 ms
53,400 KB
testcase_06 AC 38 ms
53,400 KB
testcase_07 AC 39 ms
53,400 KB
testcase_08 AC 39 ms
53,400 KB
testcase_09 AC 38 ms
53,400 KB
testcase_10 AC 39 ms
53,400 KB
testcase_11 AC 289 ms
146,588 KB
testcase_12 AC 297 ms
147,292 KB
testcase_13 AC 278 ms
146,596 KB
testcase_14 AC 269 ms
146,544 KB
testcase_15 AC 278 ms
146,548 KB
testcase_16 AC 290 ms
137,488 KB
testcase_17 AC 180 ms
136,788 KB
testcase_18 AC 324 ms
147,368 KB
testcase_19 AC 95 ms
83,428 KB
testcase_20 AC 95 ms
79,108 KB
testcase_21 AC 170 ms
102,748 KB
testcase_22 AC 174 ms
108,640 KB
testcase_23 AC 268 ms
135,708 KB
testcase_24 AC 277 ms
143,132 KB
testcase_25 AC 245 ms
126,940 KB
testcase_26 AC 224 ms
120,088 KB
testcase_27 AC 258 ms
131,176 KB
testcase_28 AC 227 ms
119,860 KB
testcase_29 AC 238 ms
131,688 KB
testcase_30 AC 177 ms
108,632 KB
testcase_31 AC 281 ms
141,204 KB
testcase_32 AC 271 ms
143,616 KB
testcase_33 AC 260 ms
137,568 KB
testcase_34 AC 290 ms
143,116 KB
testcase_35 AC 288 ms
142,244 KB
testcase_36 AC 264 ms
138,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=input()
mod=998244353

DP0=[[0]*(2*N+3) for i in range(N+1)]
DP1=[[0]*(2*N+3) for i in range(N+1)]
F=1
for i in range(N):
  if S[i]=='1':
    for j in range(-N,N+1):
      DP1[i+1][j]=(DP1[i][j]+DP0[i][j])%mod
  elif S[i]=='0':
    for j in range(-N,N+1):
      DP0[i+1][j-1]=(DP0[i+1][j-1]+DP0[i][j])%mod
      DP0[i+1][j+1]=(DP0[i+1][j+1]+DP1[i][j])%mod
    if F:
      F=0
      DP0[i+1][0]=(DP0[i+1][0]+1)%mod
  else:
    for j in range(-N,N+1):
      DP1[i+1][j]=(DP1[i][j]+DP0[i][j])%mod
    for j in range(-N,N+1):
      DP0[i+1][j-1]=(DP0[i+1][j-1]+DP0[i][j])%mod
      DP0[i+1][j+1]=(DP0[i+1][j+1]+DP1[i][j])%mod
    if F:
      DP0[i+1][0]=(DP0[i+1][0]+1)%mod
for i in range(1,N+1,2):
  F+=(DP0[N][i]+DP1[N][i])
print(F%mod)
0