結果
問題 | 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 copy from itertools import combinations, permutations, product, accumulate, groupby, chain # from more_itertools import distinct_permutations from heapq import heapify, heappop, heappush import math import bisect # from pprint import pprint from random import randint, shuffle, randrange # from sortedcontainers import SortedSet, SortedList, SortedDict import sys # sys.setrecursionlimit(2000000) input = lambda: sys.stdin.readline().rstrip('\n') inf = float('inf') mod1 = 10**9+7 mod2 = 998244353 def ceil_div(x, y): return -(-x//y) ################################################# S = input() stack = [] ans = 0 q = 0 for s in S: stack.append(s) if q == 0: if s == "<": q = 1 else: ans += len(stack) stack.clear() q = 0 elif q == 1: if s == "=": q = 2 elif s == "<": q = 1 else: ans += len(stack) stack.clear() q = 0 else: if s == "=": q = 2 elif s == ">": stack.pop() while stack[-1] == "=": stack.pop() stack.pop() if stack: if stack[-1] == "=": q = 2 elif stack[-1] == "<": q = 1 else: q = 0 elif s == "<": q = 1 ans += len(stack) print(ans)