結果

問題 No.1654 Binary Compression
ユーザー chineristACchineristAC
提出日時 2021-08-20 23:01:20
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,198 bytes
コンパイル時間 692 ms
コンパイル使用メモリ 82,336 KB
実行使用メモリ 836,408 KB
最終ジャッジ日時 2024-04-22 07:02:20
合計ジャッジ時間 17,993 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,944 KB
testcase_01 AC 39 ms
53,416 KB
testcase_02 AC 41 ms
52,352 KB
testcase_03 AC 39 ms
52,352 KB
testcase_04 AC 40 ms
52,352 KB
testcase_05 AC 39 ms
52,352 KB
testcase_06 AC 40 ms
52,480 KB
testcase_07 AC 40 ms
52,352 KB
testcase_08 AC 40 ms
52,480 KB
testcase_09 AC 40 ms
52,096 KB
testcase_10 AC 1,208 ms
445,708 KB
testcase_11 AC 1,240 ms
461,040 KB
testcase_12 AC 1,200 ms
455,340 KB
testcase_13 AC 1,230 ms
462,568 KB
testcase_14 AC 1,225 ms
460,728 KB
testcase_15 AC 1,234 ms
456,808 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 1,405 ms
460,592 KB
testcase_19 AC 1,280 ms
477,996 KB
testcase_20 AC 1,358 ms
478,452 KB
testcase_21 AC 1,260 ms
478,040 KB
testcase_22 AC 1,234 ms
478,508 KB
testcase_23 AC 283 ms
198,416 KB
testcase_24 AC 286 ms
198,128 KB
testcase_25 AC 288 ms
198,396 KB
testcase_26 AC 285 ms
198,400 KB
testcase_27 MLE -
testcase_28 MLE -
testcase_29 AC 285 ms
198,640 KB
testcase_30 AC 284 ms
198,084 KB
testcase_31 AC 286 ms
198,024 KB
testcase_32 AC 290 ms
198,528 KB
testcase_33 MLE -
testcase_34 MLE -
testcase_35 AC 290 ms
198,644 KB
testcase_36 AC 293 ms
198,768 KB
testcase_37 AC 289 ms
198,660 KB
testcase_38 AC 286 ms
198,400 KB
testcase_39 AC 286 ms
198,412 KB
testcase_40 AC 284 ms
198,560 KB
testcase_41 AC 458 ms
303,060 KB
testcase_42 AC 458 ms
303,060 KB
testcase_43 AC 457 ms
303,280 KB
testcase_44 AC 458 ms
303,280 KB
testcase_45 AC 456 ms
302,992 KB
testcase_46 AC 450 ms
303,252 KB
testcase_47 AC 39 ms
52,504 KB
testcase_48 AC 40 ms
53,156 KB
testcase_49 TLE -
testcase_50 TLE -
testcase_51 AC 820 ms
365,100 KB
testcase_52 AC 758 ms
353,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import groupby
 
s=input()
n=len(s)
s=[s[i] for i in range(n)]
mod=924844033
 
data=groupby(s)
data=[(key,len(list(group))) for key,group in data]
Start=1
End=1
if data[0][0]=="0":
    Start+=data[0][1]
    data=data[1:]
if not data:
    print(Start-1)
    exit()
 
if data[-1][0]=="0":
    End+=data[-1][1]
    data.pop()
 
comp=[0]*len(data)
for i in range(len(data)):
    comp[i]=data[i][1]
 
n=len(comp)
if n==1:
    print(comp[0]*Start*End)
    exit()
 
odd=[(comp[i],i//2) for i in range(n) if i%2==1]
#print(odd)
N=len(odd)
ID=[-1]*n
stack=[]
for i in range(N):
    while stack and stack[-1][0]<odd[i][0]:
        stack.pop()
    if stack:
        ID[2*i+1]=stack[-1][1]
    stack.append(odd[i])
 
#print(ID[1::2])
dp=[0]*n
dp[0]=comp[0]
pre=[0]*n
for i in range(2,n,2):
    id=ID[i-1]
    if id==-1:
        res=comp[i-1]*dp[i-2]
        pre[i-1]=res
        #prel[i-1]=1
    else:
        j=2*id+1
        #res=(comp[i-1]*dp[i-2]+(comp[j]-comp[i-1])*premono[j])%mod
        res=(comp[i-1]*dp[i-2]+pre[j]-comp[i-1]*dp[j-1])%mod
        pre[i-1]=res
        #prel[i-1]=prel[j]+1
    dp[i]=(comp[i]*res+dp[i-2]+comp[i])%mod
#print(pre)
#print(dp)
print((dp[-1]*Start*End)%mod)
0