結果

問題 No.2219 Re:010
ユーザー ああいいああいい
提出日時 2023-02-19 11:20:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 596 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 86,768 KB
実行使用メモリ 77,196 KB
最終ジャッジ日時 2023-09-27 18:34:39
合計ジャッジ時間 5,163 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,264 KB
testcase_01 AC 72 ms
71,176 KB
testcase_02 AC 73 ms
71,136 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 80 ms
75,960 KB
testcase_19 AC 149 ms
76,676 KB
testcase_20 AC 264 ms
76,812 KB
testcase_21 AC 71 ms
71,068 KB
testcase_22 AC 72 ms
70,948 KB
testcase_23 AC 73 ms
71,196 KB
権限があれば一括ダウンロードができます

ソースコード

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