結果
| 問題 | No.2924 <===Super Spaceship String===> |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 16:16:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,335 bytes |
| 記録 | |
| コンパイル時間 | 210 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 78,080 KB |
| 最終ジャッジ日時 | 2024-10-12 16:16:38 |
| 合計ジャッジ時間 | 4,266 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 WA * 3 TLE * 1 -- * 2 |
ソースコード
import sys
def debug(*args):
print(*args, file=sys.stderr)
s = input()
ans = len(s)
# left_list = []
# right_list = []
# i = 0
# mid_flg = False
# # add = 0
# last_left = None
# last_right = None
# for i in range(len(s)):
# if s[i] == '<':
# left_list.append(i)
# mid_flg = False
# elif s[i] == '=':
# mid_flg = True
# else:
# if mid_flg and left_list and (not right_list or left_list[-1] > right_list[-1]):
# l = left_list.pop()
# ans -= (i-l+1)
# if last_left is not None and l < last_left:
# ans += last_right-last_left+1
# debug(i, l, ans)
# last_left = l
# last_right = i
# if l > 0 and s[l-1] == '=':
# mid_flg = True
# else:
# mid_flg = False
# else:
# right_list.append(i)
# mid_flg = False
l = 0
left_list = []
# right_list = []
last_left = None
last_right = None
start_r = None
while l < len(s):
if s[l] == '<':
mid_flg = False
# if start_r is None:
# r = l + 1
# elif l >= start_r:
# r = l + 1
# start_r = None
# else:
# r = start_r
r = l+1
while r < len(s):
if s[r] == '=':
mid_flg = True
if last_left is not None and r < last_left:
r = start_r
continue
r += 1
elif s[r] == '>':
if mid_flg:
ans -= (r-l+1)
if last_left is not None and l < last_left and last_right < r:
ans += last_right-last_left+1
last_left = l
last_right = r
if left_list:
l = left_list.pop()
start_r = r + 1
else:
l = r + 1
break
else:
l = r + 1
break
else:
if r == last_left:
r = start_r
continue
else:
left_list.append(l)
l = r
break
l += 1
print(ans)