結果

問題 No.2219 Re:010
ユーザー googol_S0googol_S0
提出日時 2023-02-17 21:28:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 376 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 86,744 KB
実行使用メモリ 94,092 KB
最終ジャッジ日時 2023-09-26 18:34:44
合計ジャッジ時間 4,280 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,240 KB
testcase_01 AC 76 ms
71,252 KB
testcase_02 AC 75 ms
71,224 KB
testcase_03 AC 136 ms
93,872 KB
testcase_04 AC 93 ms
76,712 KB
testcase_05 AC 133 ms
92,184 KB
testcase_06 AC 95 ms
76,752 KB
testcase_07 AC 115 ms
86,248 KB
testcase_08 AC 137 ms
93,924 KB
testcase_09 AC 137 ms
93,848 KB
testcase_10 AC 128 ms
90,068 KB
testcase_11 AC 121 ms
88,120 KB
testcase_12 AC 122 ms
88,448 KB
testcase_13 AC 141 ms
94,056 KB
testcase_14 AC 142 ms
94,092 KB
testcase_15 AC 142 ms
94,036 KB
testcase_16 AC 141 ms
93,980 KB
testcase_17 AC 144 ms
94,008 KB
testcase_18 AC 131 ms
94,004 KB
testcase_19 AC 127 ms
93,988 KB
testcase_20 AC 133 ms
93,904 KB
testcase_21 AC 75 ms
71,328 KB
testcase_22 AC 74 ms
71,128 KB
testcase_23 AC 73 ms
71,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
mod=998244353
N=len(S)
DP=[[0,0,0,0] for i in range(N+1)]
DP[0][0]=1
for i in range(N):
  v=1
  if S[i]=='?':
    v=2
  for j in range(4):
    DP[i+1][j]=DP[i][j]*v%mod
  if S[i]=='0' or S[i]=='?':
    DP[i+1][1]=(DP[i+1][1]+DP[i][0])%mod
    DP[i+1][3]=(DP[i+1][3]+DP[i][2])%mod
  if S[i]=='1' or S[i]=='?':
    DP[i+1][2]=(DP[i+1][2]+DP[i][1])%mod
print(DP[N][3])
0