結果

問題 No.2219 Re:010
ユーザー ああいいああいい
提出日時 2023-02-19 11:23:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 398 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 77,548 KB
最終ジャッジ日時 2023-09-27 18:35:51
合計ジャッジ時間 5,735 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,360 KB
testcase_01 AC 64 ms
71,328 KB
testcase_02 AC 67 ms
71,404 KB
testcase_03 AC 254 ms
77,548 KB
testcase_04 AC 101 ms
76,516 KB
testcase_05 AC 221 ms
77,204 KB
testcase_06 AC 117 ms
77,040 KB
testcase_07 AC 160 ms
76,700 KB
testcase_08 AC 241 ms
77,428 KB
testcase_09 AC 238 ms
77,268 KB
testcase_10 AC 198 ms
76,828 KB
testcase_11 AC 179 ms
76,984 KB
testcase_12 AC 179 ms
77,024 KB
testcase_13 AC 289 ms
77,224 KB
testcase_14 AC 285 ms
77,480 KB
testcase_15 AC 289 ms
77,340 KB
testcase_16 AC 282 ms
77,116 KB
testcase_17 AC 283 ms
77,444 KB
testcase_18 AC 71 ms
76,128 KB
testcase_19 AC 127 ms
77,396 KB
testcase_20 AC 398 ms
77,160 KB
testcase_21 AC 67 ms
71,420 KB
testcase_22 AC 66 ms
71,256 KB
testcase_23 AC 68 ms
71,168 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 * pow(2,hh,P) % P + hh * pow(2,hh - 1,P)
        t2 = zero * pow(2,h,P) % P + h * pow(2,h - 1,P)
        ans += t1 * t2 % P
        ans %= P
    elif s == "?":
        h -= 1
        t1 = hz * pow(2,hh,P) % P+ hh * pow(2,hh - 1,P)
        t2 = zero * pow(2,h,P) % 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