結果

問題 No.2924 <===Super Spaceship String===>
ユーザー 👑 loop0919
提出日時 2024-09-16 01:31:51
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 692 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 136,116 KB
最終ジャッジ日時 2024-10-12 07:56:51
合計ジャッジ時間 2,149 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 6 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import groupby

S = list(input())
rle_S = []

for s, array in groupby(S):
    if s == "=":
        rle_S.append((s, len(list(array))))
    else:
        rle_S.extend([(s, 1)] * len(list(array)))

stack = []

for s, length in rle_S:
    stack.append((s, length))
    if len(stack) >= 2:
        pre_s, pre_length = stack[-2]
        if pre_s == s == "=":
            stack.pop()
            stack.pop()
            stacn.append((s, length + pre_length))
    
    if len(stack) >= 3:
        pre2_s, pre2_length = stack[-3]
        if pre2_s + pre_s + s == "<=>":
            stack.pop()
            stack.pop()
            stack.pop()

print(sum(length for _, length in stack))
0