結果

問題 No.2924 <===Super Spaceship String===>
ユーザー yamasaKit_
提出日時 2025-02-01 00:03:34
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,046 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 73,304 KB
最終ジャッジ日時 2025-02-01 00:03:38
合計ジャッジ時間 4,713 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 7 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import cache, partial
from pprint import pprint
import sys
from typing import Any, Final

try:
    from icecream import ic
except ImportError:  # Graceful fallback if IceCream isn't installed.
    ic = lambda *a: None if not a else (a[0] if len(a) == 1 else a)  # noqa
debug = partial(print, file=sys.stderr)
dpprint = partial(pprint, stream=sys.stderr)
sys.setrecursionlimit(10**6)
MOD = 998244353

S_ = input()
N = len(S_)
S = []
cnt = 0
for s in S_:
    if s == "<" or s == ">":
        if cnt > 0:
            S.append(("=", cnt))
        S.append((s, 1))
        cnt = 0
    else:
        cnt += 1
ic(S)

ans = N
stack = []
for char, cnt in S:
    if char in ["<", "="]:
        stack.append((char, cnt))
        continue
    else:
        if len(stack) >= 2 and stack[-1][0] == "=" and stack[-2][0] == "<":
            ans -= 2 + stack[-1][1]
            ic(cnt)
            stack.pop()
            stack.pop()
        else:
            stack.append((char, cnt))

print(ans)
0