結果

問題 No.1894 Delete AB
ユーザー ああいい
提出日時 2022-04-08 21:35:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 507 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,848 KB
実行使用メモリ 79,508 KB
最終ジャッジ日時 2024-11-28 12:12:05
合計ジャッジ時間 2,351 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 1 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

for _ in range(T):
    N = int(input())
    S = input()
    
    ans = []
    left = 0
    while left < N:
        right = left
        count = 0
        while right < N and count <= 0:
            if S[right] == "A":
                count -= 1
            else:
                count += 1
            right += 1
        if count <= 0:
            ans.append(S[left:right])
            left = right
        else:
            ans.append("B")
            left = right
    print("".join(ans))
0