結果

問題 No.1894 Delete AB
ユーザー tamatotamato
提出日時 2022-04-08 21:51:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 90,068 KB
最終ジャッジ日時 2023-08-19 00:28:17
合計ジャッジ時間 3,094 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,268 KB
testcase_01 AC 103 ms
77,164 KB
testcase_02 AC 111 ms
77,240 KB
testcase_03 AC 111 ms
77,548 KB
testcase_04 AC 103 ms
77,400 KB
testcase_05 AC 104 ms
77,280 KB
testcase_06 AC 114 ms
77,976 KB
testcase_07 AC 105 ms
77,472 KB
testcase_08 AC 115 ms
77,584 KB
testcase_09 AC 102 ms
77,196 KB
testcase_10 AC 107 ms
77,752 KB
testcase_11 AC 96 ms
76,408 KB
testcase_12 AC 96 ms
76,624 KB
testcase_13 AC 111 ms
84,876 KB
testcase_14 AC 120 ms
90,068 KB
権限があれば一括ダウンロードができます

ソースコード

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