結果

問題 No.2219 Re:010
ユーザー first_vilfirst_vil
提出日時 2023-02-18 10:23:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 86,924 KB
実行使用メモリ 78,848 KB
最終ジャッジ日時 2023-09-27 04:23:15
合計ジャッジ時間 4,149 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,396 KB
testcase_01 AC 76 ms
71,340 KB
testcase_02 AC 70 ms
71,344 KB
testcase_03 AC 89 ms
78,120 KB
testcase_04 AC 81 ms
76,364 KB
testcase_05 AC 89 ms
77,516 KB
testcase_06 AC 84 ms
76,708 KB
testcase_07 AC 87 ms
76,952 KB
testcase_08 AC 92 ms
77,992 KB
testcase_09 AC 91 ms
77,872 KB
testcase_10 AC 89 ms
77,252 KB
testcase_11 AC 87 ms
76,964 KB
testcase_12 AC 86 ms
77,124 KB
testcase_13 AC 94 ms
78,824 KB
testcase_14 AC 93 ms
78,704 KB
testcase_15 AC 96 ms
78,764 KB
testcase_16 AC 91 ms
78,848 KB
testcase_17 AC 94 ms
78,808 KB
testcase_18 AC 84 ms
78,224 KB
testcase_19 AC 84 ms
78,344 KB
testcase_20 AC 86 ms
78,248 KB
testcase_21 AC 70 ms
71,508 KB
testcase_22 AC 72 ms
71,312 KB
testcase_23 AC 68 ms
71,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

int1 = lambda x: int(x) - 1

# input = lambda: sys.stdin.buffer.readline()
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
i1 = lambda: int1(input())
mi = lambda: map(int, input().split())
mi1 = lambda: map(int1, input().split())
li = lambda: list(mi())
li1 = lambda: list(mi1())
lli = lambda n: [li() for _ in range(n)]

INF = float("inf")
# mod = int(1e9 + 7)
mod = 998244353

s = input()
l = [0, 0, 0]
t = "01?"
r = [s.count(c) for c in t]
n = len(s)
p2 = [1] * n
for i in range(n - 1):
    p2[i + 1] = p2[i] * 2 % mod
ans = 0
for c in s:
    r[t.index(c)] -= 1
    le = (l[0] * p2[l[2]] + l[2] * p2[l[2] - 1]) % mod
    ri = (r[0] * p2[r[2]] + r[2] * p2[r[2] - 1]) % mod
    if c != "0":
        ans = (ans + le * ri) % mod
    l[t.index(c)] += 1
print(ans)
0