結果
| 問題 | No.2924 <===Super Spaceship String===> | 
| コンテスト | |
| ユーザー |  ちーぴん | 
| 提出日時 | 2024-10-13 23:13:45 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 288 ms / 2,000 ms | 
| コード長 | 690 bytes | 
| コンパイル時間 | 165 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 189,640 KB | 
| 最終ジャッジ日時 | 2024-10-16 17:56:17 | 
| 合計ジャッジ時間 | 2,090 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 12 | 
ソースコード
S = input()
C = []
run = 0
for c in S:
    if c == "<" or c == ">":
        C.append([c, 1])
    else:
        if len(C) > 0 and C[-1][0] == "=":
            C[-1][1] += 1
        else:
            C.append(["=", 1])
def found(stack):
    if len(stack) < 3:
        return False
    if stack[-3][0] == "<" and stack[-2][0] == "=" and stack[-1][0] == ">":
        return True
    return False
stack = []
for c, length in C:
    if c == "=" and len(stack) > 0 and stack[-1][0] == "=":
        stack[-1][1] += length
        continue
    stack.append([c, length])
    if found(stack):
        for _ in range(3):
            stack.pop()
ans = sum([length for _, length in stack])
print(ans)
            
            
            
        