// No.559 swapAB列 // https://yukicoder.me/problems/no/559 // #include #include #include #include #include using namespace std; vector check_A_positions(string &S); int main() { string S; cin >> S; vector res = check_A_positions(S); int after_swap = (0 + res.size()-1) * res.size() / 2; int current_status = accumulate(res.begin(), res.end(), 0); cout << current_status - after_swap << endl; } vector check_A_positions(string &S) { vector res; for (auto i = 0; i < S.size(); ++i) { if (S[i] == 'A') res.push_back(i); } return res; }