-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathB.cpp
48 lines (45 loc) · 973 Bytes
/
B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(i=0;i<n;i++)
#define fo2(i,start,end) for(i=start;i<=end;i++)
#define rfo(i,n) for(i=n-1;i>=0;i--)
#define lli long long int
#define deb(x) cout<<#x<<"="<<x<<endl
#define deb2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define tr(it,a) for(auto it=a.begin(); it!=a.end();it++)
#define nl '\n'
#define PI 3.141592653589793238
#define mod 1000000007
void solve(){
int i,j;
int n,zero=0,one=0,count;
char last;
cin>>n;
string s;
cin>>s;
fo(i,n-1){
if(s[i]==s[i+1]){
if(s[i]=='1'){
one++;
}
else{
zero++;
}
}
}
count=max(one,zero);
cout<<count<<nl;
}
int main(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t=1;
cin>>t;
while(t--){
solve();
}
return 0;
}