結果

問題 No.559 swapAB列
ユーザー nnasennnasen
提出日時 2017-12-03 09:49:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 514 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 165,024 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 22:38:42
合計ジャッジ時間 2,146 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define SZ(n) (int)(n).size()
#define ALL(n) (n).begin(), (n).end()
#define MOD % 1000000007
using namespace std;
typedef long long LL;
typedef vector<int> VI;


int main() {
	string s;
	cin >> s;
	if (SZ(s) == 1) cout << 0 << endl;
	else {
		int cnt = 0;
		REP(i, SZ(s)) {
			if (s[i] == 'B' && s[i + 1] == 'A') {
				swap(s[i], s[i + 1]);
				cnt++;
				i = 0;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}
0