結果

問題 No.2219 Re:010
ユーザー 👑 KazunKazun
提出日時 2022-01-27 21:44:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 78,848 KB
最終ジャッジ日時 2023-08-26 23:51:21
合計ジャッジ時間 4,260 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,196 KB
testcase_01 AC 70 ms
71,456 KB
testcase_02 AC 71 ms
71,588 KB
testcase_03 AC 113 ms
78,848 KB
testcase_04 AC 89 ms
77,032 KB
testcase_05 AC 104 ms
78,068 KB
testcase_06 AC 92 ms
77,248 KB
testcase_07 AC 97 ms
77,464 KB
testcase_08 AC 108 ms
78,200 KB
testcase_09 AC 107 ms
78,416 KB
testcase_10 AC 102 ms
77,764 KB
testcase_11 AC 99 ms
77,888 KB
testcase_12 AC 101 ms
77,752 KB
testcase_13 AC 113 ms
78,832 KB
testcase_14 AC 115 ms
78,764 KB
testcase_15 AC 112 ms
78,828 KB
testcase_16 AC 112 ms
78,836 KB
testcase_17 AC 112 ms
78,836 KB
testcase_18 AC 79 ms
78,088 KB
testcase_19 AC 106 ms
78,700 KB
testcase_20 AC 108 ms
78,528 KB
testcase_21 AC 70 ms
71,564 KB
testcase_22 AC 70 ms
71,300 KB
testcase_23 AC 69 ms
71,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def mod_product(*X):
    y=1
    for x in X:
        y*=x; y%=Mod
    return y

S=input()

a=b=0
c=S.count("0"); d=S.count("?")

Mod=998244353

TWO=[1]*(len(S)+1)
for i in range(1,len(S)+1):
    TWO[i]=(2*TWO[i-1])%Mod

four_inv=pow(4,Mod-2,Mod)

Ans=0
for s in S:
    if s=="0":
        c-=1
    elif s=="?":
        d-=1

    if s!="0":
        Ans+=mod_product(2*a+b,2*c+d,TWO[b+d])
        Ans%=Mod

    if s=="0":
        a+=1
    elif s=="?":
        b+=1

Ans*=four_inv; Ans%=Mod

print(Ans)
0