結果

問題 No.1894 Delete AB
ユーザー kohei2019kohei2019
提出日時 2023-07-13 22:36:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 980 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 83,520 KB
最終ジャッジ日時 2023-10-13 11:26:07
合計ジャッジ時間 3,305 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,500 KB
testcase_01 AC 82 ms
76,760 KB
testcase_02 AC 78 ms
76,708 KB
testcase_03 AC 123 ms
77,872 KB
testcase_04 AC 133 ms
78,460 KB
testcase_05 AC 112 ms
77,936 KB
testcase_06 AC 150 ms
79,744 KB
testcase_07 AC 121 ms
77,964 KB
testcase_08 AC 122 ms
77,772 KB
testcase_09 AC 106 ms
77,800 KB
testcase_10 AC 98 ms
76,948 KB
testcase_11 AC 84 ms
76,152 KB
testcase_12 AC 85 ms
76,424 KB
testcase_13 AC 84 ms
83,520 KB
testcase_14 AC 76 ms
76,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
ansls = []
for i in range(T):
    n = int(input())
    S = input()
    ans = []
    cntB = 0
    for j in range(n-1,-1,-1):
        if S[j] == 'B':
            cntB += 1
            ans.append('B')
        elif cntB > 1:
            cntB -= 1
            ans.pop()
        else:
            cntB = 0
            ans.append('A')
    ans.reverse()
    ansls.append(''.join(ans))
for ans in ansls:
    print(ans)
0