結果

問題 No.3395 Range Flipping Game
コンテスト
ユーザー Yakumo221
提出日時 2025-12-02 17:52:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 435 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 82,920 KB
実行使用メモリ 88,944 KB
最終ジャッジ日時 2025-12-02 17:52:23
合計ジャッジ時間 5,355 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

t = int(input())
while t:
	t -= 1
	
	n = int(input())
	s = input()
	
	if n == 1:
		print("B")
		continue
	if n == 2:
		print("BB")
		continue
	
	s = list(s)

	if s[0] == s[1] == "B":
		pass
	elif (s[0] == "A") & (s[1] == "B") & (s[2] == "A"):
		s[0] = "B"
		i = 2
		while i < n:
			if s[i] == "A":
				i += 1
				continue
			while i < n:
				if s[i] == "B":
					s[i] = "A"
					i += 1
					continue
				else:
					break
			break
	else:
		s[0] = "B"
		s[1] = "B"
		if s[2] == "A":
			pass
		else:
			i = 2
			while i < n:
				if s[i] == "A":
					break
				else:
					s[i] = "A"
					i += 1
			

	print("".join(s))
0