#P3819. A and B Problem
A and B Problem
Problem Description
After calculating A + B, let’s consider another easy problem which only contains A and B.
You are given a string s containing only the letters 'A' and 'B'. The letters are arranged in a circle, so the last and first characters are adjacent. You will perform a series of swaps until all the 'A's form one consecutive sequence and all the 'B's form another consecutive sequence. In each swap, you can select any two characters and swap them. Find the minimal number of swaps necessary to reach your goal.
Input
The first line contains a single integer T, indicating the number of test cases.
Each test case only contains a string as description.
Technical Specification
1. 1 <= T <= 100
2. 1 <= |S| <= 100000, |S| indicating the length of the string.
Output
For each test case, output the case number first, then the minimal number of swaps.
3
AABB
ABAB
AABABA
Case 1: 0
Case 2: 1
Case 3: 1
Author
iSea@WHU