結果

問題 No.2219 Re:010
ユーザー ああいいああいい
提出日時 2023-02-19 11:20:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 596 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 76,544 KB
最終ジャッジ日時 2024-07-20 13:03:44
合計ジャッジ時間 3,592 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()

zero = 0
h = 0
for s in S:
    if s == "0":
        zero += 1
    elif s == "?":
        h += 1
P = 998244353
hz = 0
hh = 0
ans = 0
for s in S:
    if s == "1":
        t1 = hz * (hh + 1) % P + hh * pow(2,hh - 1,P)
        t2 = zero * (h + 1) % P + h * pow(2,h - 1,P)
        ans += t1 * t2 % P
        ans %= P
    elif s == "?":
        h -= 1
        t1 = hz * (hh + 1) % P+ hh * pow(2,hh - 1,P)
        t2 = zero * (h + 1) % P + h * pow(2,h - 1,P)
        ans += t1 * t2 % P
        ans %= P
        hh += 1
    else:
        zero -= 1
        hz += 1
    #print(ans)
print(ans)
0