結果

問題 No.2219 Re:010
ユーザー とりゐとりゐ
提出日時 2023-02-17 21:33:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 77,252 KB
最終ジャッジ日時 2023-09-26 18:43:23
合計ジャッジ時間 4,531 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,192 KB
testcase_01 AC 75 ms
71,268 KB
testcase_02 AC 74 ms
71,212 KB
testcase_03 AC 131 ms
76,980 KB
testcase_04 AC 98 ms
76,656 KB
testcase_05 AC 117 ms
76,948 KB
testcase_06 AC 100 ms
76,828 KB
testcase_07 AC 108 ms
76,960 KB
testcase_08 AC 121 ms
77,140 KB
testcase_09 AC 121 ms
76,988 KB
testcase_10 AC 115 ms
76,964 KB
testcase_11 AC 114 ms
76,940 KB
testcase_12 AC 112 ms
76,920 KB
testcase_13 AC 132 ms
77,252 KB
testcase_14 AC 132 ms
77,244 KB
testcase_15 AC 128 ms
77,200 KB
testcase_16 AC 130 ms
77,028 KB
testcase_17 AC 129 ms
77,180 KB
testcase_18 AC 110 ms
76,944 KB
testcase_19 AC 109 ms
76,864 KB
testcase_20 AC 117 ms
77,040 KB
testcase_21 AC 75 ms
70,928 KB
testcase_22 AC 74 ms
71,108 KB
testcase_23 AC 74 ms
71,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353

s=input()
n=len(s)

dp=[0,0]
ans=0
inv2=pow(2,mod-2,mod)
cnt=0
for i in s:
  ndp=[0,0]
  if i=='0':
    ans+=dp[1]
    ndp[0]=dp[0]+1
    ndp[1]=dp[1]
  if i=='1':
    ndp[0]=dp[0]
    ndp[1]=dp[0]+dp[1]
  if i=='?':
    cnt+=1
    ans+=dp[1]*inv2
    ndp[1]=dp[1]+dp[0]*inv2
    ndp[0]=dp[0]+inv2
  dp=[i%mod for i in ndp]
  

print(ans*pow(2,cnt,mod)%mod)
0