筆者はレート800前後の茶~緑コーダ
ABC当日にACできなかった問題を解いていく
ABCの問題を解いていく
実装コード
スタックを使う問題らしい
文字列を順番に配列積んで行き
末尾がABCになったらpopして除去
main.py
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, Counter, deque
from functools import reduce, lru_cache
from itertools import product, accumulate, groupby, combinations
import sys
import os
def rI(): return int(sys.stdin.readline().rstrip())
def rLI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def rI1(): return (int(sys.stdin.readline().rstrip())-1)
def rLI1(): return list(map(lambda a:int(a)-1,sys.stdin.readline().rstrip().split()))
def rS(): return sys.stdin.readline().rstrip()
def rLS(): return list(sys.stdin.readline().rstrip().split())
IS_LOCAL = int(os.getenv("ATCODER", "0"))==0
err = (lambda *args, **kwargs: print(*args, **kwargs, file=sys.stderr)) if IS_LOCAL else (lambda *args, **kwargs: None)
def main():
S = rS()
ans = []
for s in S:
ans.append(s)
if len(ans) >= 3:
if ans[-3:]==["A","B","C"]:
for _ in range(3):
ans.pop()
print("".join(ans))
if __name__ == '__main__':
main()
感想
やりたい処理は一見複雑そうに見えたけどスタックをスタックを使えば瞬殺なのは驚き