結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
70,748 KB
testcase_01 AC 64 ms
70,964 KB
testcase_02 AC 66 ms
71,072 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 70 ms
76,000 KB
testcase_19 AC 126 ms
76,936 KB
testcase_20 AC 247 ms
76,588 KB
testcase_21 AC 65 ms
70,960 KB
testcase_22 AC 66 ms
71,028 KB
testcase_23 AC 65 ms
70,940 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) + hh * pow(2,hh - 1,P)
        t2 = zero * (h + 1) + h * pow(2,h - 1,P)
        ans += t1 * t2 % P
        ans %= P
    elif s == "?":
        h -= 1
        t1 = hz * (hh + 1) + hh * pow(2,hh - 1,P)
        t2 = zero * (h + 1) + h * pow(2,h - 1,P)
        ans += t1 * t2 % P
        ans %= P
        hh += 1
    else:
        zero -= 1
        hz += 1
    #print(ans)
print(ans)
0