結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー |
![]() |
提出日時 | 2024-10-12 15:33:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 1,522 bytes |
コンパイル時間 | 233 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 113,572 KB |
最終ジャッジ日時 | 2024-10-16 17:54:35 |
合計ジャッジ時間 | 2,048 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
from collections import defaultdict, deque, Counter# from functools import cache# import copyfrom itertools import combinations, permutations, product, accumulate, groupby, chain# from more_itertools import distinct_permutationsfrom heapq import heapify, heappop, heappushimport mathimport bisect# from pprint import pprintfrom random import randint, shuffle, randrange# from sortedcontainers import SortedSet, SortedList, SortedDictimport sys# sys.setrecursionlimit(2000000)input = lambda: sys.stdin.readline().rstrip('\n')inf = float('inf')mod1 = 10**9+7mod2 = 998244353def ceil_div(x, y): return -(-x//y)#################################################S = input()stack = []ans = 0q = 0for s in S:stack.append(s)if q == 0:if s == "<":q = 1else:ans += len(stack)stack.clear()q = 0elif q == 1:if s == "=":q = 2elif s == "<":q = 1else:ans += len(stack)stack.clear()q = 0else:if s == "=":q = 2elif s == ">":stack.pop()while stack[-1] == "=":stack.pop()stack.pop()if stack:if stack[-1] == "=":q = 2elif stack[-1] == "<":q = 1else:q = 0elif s == "<":q = 1ans += len(stack)print(ans)