結果

問題 No.2924 <===Super Spaceship String===>
ユーザー ryuuichiryuuichi
提出日時 2024-10-12 16:52:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 64,556 KB
最終ジャッジ日時 2024-10-12 16:52:18
合計ジャッジ時間 5,203 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,624 KB
testcase_01 AC 29 ms
10,496 KB
testcase_02 AC 29 ms
10,496 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 32 ms
10,624 KB
testcase_07 WA -
testcase_08 AC 551 ms
58,412 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

S=list(input())
#ラングトン符号化→スタック
s=[]
N=len(S)
for i in range(N):
    s.append([S[i],1])
ss=[s[0]]
for i in range(1,N):
    
    if ss[-1][0]==s[i][0]:
        ss[-1][1]+=s[i][1]
    else:
        ss.append(s[i])


mai=0
stac=[]
for i in range(len(ss)):
    if len(stac)>=2:
        if stac[-1][0]==stac[-2][0]:
            stac[-1][1]+=stac[-2][1]
    if len(stac)>=3:
        if stac[-3][0]=="<" and stac[-2][0]=="=" and stac[-1][0]==">":
            mai+=stac[-2][1]+2
            tmp=[stac[-3][1]-1,stac[-1][1]-1]
            for _ in range(3):
                stac.pop()
            if tmp[0]:
                stac.append(["<",tmp[0]])
            if tmp[1]:
                stac.append(["<",tmp[1]])
    stac.append(ss[i])

print(N-mai)
    
0