結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー | kmmtkm |
提出日時 | 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 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
56,704 KB |
testcase_01 | AC | 39 ms
51,712 KB |
testcase_02 | AC | 39 ms
51,712 KB |
testcase_03 | AC | 39 ms
51,456 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 39 ms
52,224 KB |
testcase_07 | AC | 48 ms
60,032 KB |
testcase_08 | AC | 47 ms
59,904 KB |
testcase_09 | WA | - |
testcase_10 | TLE | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
ソースコード
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)