結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー |
|
提出日時 | 2024-10-12 16:42:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 126 ms / 2,000 ms |
コード長 | 1,152 bytes |
コンパイル時間 | 324 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 100,480 KB |
最終ジャッジ日時 | 2024-10-16 17:55:38 |
合計ジャッジ時間 | 2,088 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
import sys import math from itertools import product, permutations, combinations, accumulate from heapq import heapify, heappush, heappop from collections import deque, defaultdict, Counter from bisect import bisect, bisect_left, bisect_right from copy import copy, deepcopy #from sortedcontainers import SortedSet, SortedList, SortedDict sys.setrecursionlimit(10**7) INF = float('inf') LINF = 1 << 60 MOD = 10**9+7 def mii(): return map(int, sys.stdin.readline().split()) S = input() N = len(S) st = deque() cut = 0 cur = 0 now = 0 for i in range(N): c = S[i] if c == "<": st.append((i, "<")) elif c == "=": st.append((i, "=")) elif c == ">": cnt = 0 while len(st) > 0 and st[-1][1] == "=": cnt += 1 st.pop() if len(st) == 0: continue if cnt == 0: st.clear() cut += now now = 0 continue if st[-1][1] == "<": now += cnt + 2 st.pop() else: st.clear() cut += now now = 0 cut += now print(N - cut)