結果

問題 No.1654 Binary Compression
ユーザー chocoruskchocorusk
提出日時 2021-07-31 05:41:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 131,596 KB
最終ジャッジ日時 2024-04-22 03:27:53
合計ジャッジ時間 9,916 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 38 ms
51,584 KB
testcase_02 AC 39 ms
52,096 KB
testcase_03 AC 39 ms
51,968 KB
testcase_04 AC 40 ms
51,968 KB
testcase_05 AC 39 ms
51,968 KB
testcase_06 AC 40 ms
51,968 KB
testcase_07 AC 39 ms
52,480 KB
testcase_08 AC 40 ms
51,584 KB
testcase_09 AC 39 ms
51,968 KB
testcase_10 AC 220 ms
128,896 KB
testcase_11 AC 234 ms
129,740 KB
testcase_12 AC 197 ms
128,000 KB
testcase_13 AC 215 ms
130,944 KB
testcase_14 AC 199 ms
129,536 KB
testcase_15 AC 210 ms
130,816 KB
testcase_16 AC 178 ms
131,196 KB
testcase_17 AC 184 ms
131,328 KB
testcase_18 AC 212 ms
131,200 KB
testcase_19 AC 208 ms
131,456 KB
testcase_20 AC 204 ms
131,072 KB
testcase_21 AC 192 ms
128,128 KB
testcase_22 AC 204 ms
131,072 KB
testcase_23 AC 124 ms
126,848 KB
testcase_24 AC 128 ms
124,928 KB
testcase_25 AC 130 ms
128,128 KB
testcase_26 AC 128 ms
125,184 KB
testcase_27 AC 184 ms
131,328 KB
testcase_28 AC 190 ms
131,560 KB
testcase_29 AC 137 ms
128,384 KB
testcase_30 AC 137 ms
128,616 KB
testcase_31 AC 127 ms
128,584 KB
testcase_32 AC 134 ms
131,200 KB
testcase_33 AC 177 ms
131,596 KB
testcase_34 AC 180 ms
131,456 KB
testcase_35 AC 141 ms
131,456 KB
testcase_36 AC 132 ms
129,180 KB
testcase_37 AC 140 ms
131,072 KB
testcase_38 AC 144 ms
131,200 KB
testcase_39 AC 137 ms
128,512 KB
testcase_40 AC 141 ms
128,384 KB
testcase_41 AC 122 ms
124,288 KB
testcase_42 AC 66 ms
73,344 KB
testcase_43 AC 68 ms
72,832 KB
testcase_44 AC 121 ms
124,024 KB
testcase_45 AC 116 ms
121,112 KB
testcase_46 AC 66 ms
73,344 KB
testcase_47 AC 39 ms
51,584 KB
testcase_48 AC 39 ms
51,968 KB
testcase_49 AC 170 ms
128,592 KB
testcase_50 AC 168 ms
128,256 KB
testcase_51 AC 168 ms
128,128 KB
testcase_52 AC 174 ms
131,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD=924844033
s=input()
n=len(s)
l=0
while l<n and s[l]=='0':
    l+=1
if l==n:
    print(n)
    exit()
r=n-1
while r>=0 and s[r]=='0':
    r-=1
c=(l+1)*(n-r)
s=s[l:r+1]
n=len(s)
dp=[0]*n
dps=[0]*(n+1)
dp[0]=1
dps[1]=1
pr=0
st=[(n+1, 0)]
for i in range(1, n):
    dps[i+1]=dps[i]
    if s[i]=='1':
        dp[i]+=dp[i-1]
        if pr<i-1:
            dp[i]+=dp[pr]
        dp[i]%=MOD
        pr=i
        dps[i+1]+=dp[i]
        dps[i+1]%=MOD
    elif s[i]=='0' and s[i+1]=='1':
        d=i-pr
        ipr=i
        dpr=0
        while st:
            p=st[-1]
            dp[i]+=(dps[ipr]-dps[p[1]]+MOD)*(d-dpr)
            dp[i]%=MOD
            if p[0]>d:
                break
            ipr=p[1]
            dpr=p[0]
            st.pop()
        st.append((d, i))
print(dps[n]*c%MOD)
0