3022: Boys and Girls

时间限制:1000 ms 内存限制:128 MB
上传者:
提交:48 通过:5

题目描述

AA is a kindergarten teacher, there are $n$ boys and $n$ girls in her class. Chairs in the classroom are put in a row, children select their seats according to their own preferences. However, AA wants to make boys and girls sit alternately. That is to say, if $n = 2$, 'B' said a boy and 'G' said a girl, she wants her children sit like "BGBG" or "GBGB". So she decides to make some changes, each time she chooses two adjacent children and swap their seats. Now she wants to know how many times she needs to swap at least.

输入格式

The first line contains an integer number T, the number of test cases.

For each test case :
The first line contains an integer $n$($1 \leq n \leq 10^{5}$), the number of boys and girls.

The next line contains a string $s$ consists of 'B' and 'G', representing the initial seats of children.

It's guaranteed that $|s| = 2n$ and both 'B' and 'G' appear exactly $n$ times in the string $s$.

输出格式

For each test case print a number, the minimum number of times required.

输入样例 复制

2
1
GB
2
BBGG

输出样例 复制

0
1