結果
| 問題 | No.559 swapAB列 |
| コンテスト | |
| ユーザー |
moko_freedom
|
| 提出日時 | 2017-08-26 07:50:29 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 691 bytes |
| 記録 | |
| コンパイル時間 | 966 ms |
| コンパイル使用メモリ | 181,152 KB |
| 実行使用メモリ | 11,424 KB |
| 最終ジャッジ日時 | 2026-05-05 06:12:43 |
| 合計ジャッジ時間 | 4,793 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | TLE * 1 -- * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PI;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
if (s.size() == 1) {
cout << 0 << endl;
}
int a = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'A') a++;
}
int ans = 0;
int pos = 0;
while (true) {
bool flag = false;
for (int i = pos; i < s.size(); i++) {
if (s[i] == 'B' && s[i+1] == 'A') {
s[i] = 'A'; s[i+1] = 'B';
ans++;
break;
}
}
pos = s.find('B') - 1;
//cout << s << pos << endl;
if (pos + 1 == a) {
break;
}
}
cout << ans << endl;
return 0;
}
moko_freedom