結果

問題 No.559 swapAB列
ユーザー doraeeemonndoraeeemonn
提出日時 2017-11-28 21:03:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 206 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 10,492 KB
実行使用メモリ 7,888 KB
最終ジャッジ日時 2023-08-18 09:18:06
合計ジャッジ時間 1,476 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,728 KB
testcase_01 AC 16 ms
7,752 KB
testcase_02 AC 15 ms
7,788 KB
testcase_03 AC 16 ms
7,784 KB
testcase_04 AC 16 ms
7,768 KB
testcase_05 AC 15 ms
7,788 KB
testcase_06 AC 15 ms
7,696 KB
testcase_07 AC 15 ms
7,888 KB
testcase_08 AC 16 ms
7,736 KB
testcase_09 AC 16 ms
7,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

arg = list(input())
count = 0
i = 0
while(i < len(arg)-1):
	if arg[i] == 'B' and arg[i+1] == 'A':
		arg[i] = 'A'
		arg[i+1] = 'B'
		count += 1
		if i > 0 and arg[i-1] == 'B':
			i -= 2
	i += 1
print(count)
0