結果
| 問題 | No.2924 <===Super Spaceship String===> |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 15:20:36 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 883 bytes |
| 記録 | |
| コンパイル時間 | 256 ms |
| コンパイル使用メモリ | 82,160 KB |
| 実行使用メモリ | 88,512 KB |
| 最終ジャッジ日時 | 2024-10-12 15:20:38 |
| 合計ジャッジ時間 | 1,655 ms |
|
ジャッジサーバーID (参考情報) |
judge / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 7 WA * 4 |
ソースコード
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
print(ans)