結果

問題 No.1894 Delete AB
ユーザー tamato
提出日時 2022-04-08 21:51:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 89,252 KB
最終ジャッジ日時 2024-11-28 12:31:51
合計ジャッジ時間 2,378 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    for _ in range(int(input())):
        N = int(input())
        S = input().rstrip('\n')

        T = []
        for s in S:
            T.append(s)
            while len(T) >= 3:
                if T[-3:] == ["A", "B", "B"]:
                    T.pop()
                    T.pop()
                    T.pop()
                    T.append("B")
                else:
                    break
        print("".join(T))


if __name__ == '__main__':
    main()
0