結果

問題 No.2219 Re:010
ユーザー HydruHydru
提出日時 2023-02-18 00:00:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 413 bytes
コンパイル時間 683 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 90,764 KB
最終ジャッジ日時 2023-09-26 21:17:44
合計ジャッジ時間 4,735 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,136 KB
testcase_01 AC 78 ms
71,260 KB
testcase_02 AC 78 ms
71,036 KB
testcase_03 AC 147 ms
89,224 KB
testcase_04 AC 92 ms
76,892 KB
testcase_05 AC 120 ms
86,312 KB
testcase_06 AC 97 ms
78,428 KB
testcase_07 AC 113 ms
81,632 KB
testcase_08 AC 133 ms
87,288 KB
testcase_09 AC 126 ms
87,708 KB
testcase_10 AC 117 ms
84,788 KB
testcase_11 AC 112 ms
83,124 KB
testcase_12 AC 112 ms
82,944 KB
testcase_13 AC 135 ms
90,708 KB
testcase_14 AC 135 ms
90,736 KB
testcase_15 AC 136 ms
90,532 KB
testcase_16 AC 139 ms
90,764 KB
testcase_17 AC 137 ms
90,652 KB
testcase_18 AC 109 ms
90,256 KB
testcase_19 AC 112 ms
90,520 KB
testcase_20 AC 134 ms
90,724 KB
testcase_21 AC 76 ms
71,512 KB
testcase_22 AC 77 ms
71,296 KB
testcase_23 AC 76 ms
71,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353

S=input()
len_S=len(S)

pow_2=[1]
for _ in range(len_S+1):
    pow_2.append(pow_2[-1]*2%mod)

D={"0":0,"1":1,"?":2}

cntr=[0,0,0]
cntl=[0,0,0]
for s in S:
    cntr[D[s]]+=1

ans=0
for s in S:
    cntr[D[s]]-=1
    if s!="0":
        x=cntl[2]
        y=cntr[2]
        ans+=(cntl[0]*pow_2[x]+x*pow_2[max(0,x-1)])*(cntr[0]*pow_2[y]+y*pow_2[max(0,y-1)])
        ans%=mod
    cntl[D[s]]+=1

print(ans)
0