Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int t;
- cin>>t;
- while(t--){
- int n;
- string s;
- cin>>n>>s;
- int a=0, b=0;
- int f=0;
- for(auto e: s)
- {
- if(f+'0' == e)
- f ^= 1;
- else
- a++;
- }
- f=1;
- for(auto e: s)
- {
- if(f+'0' == e)
- f ^= 1;
- else
- b++;
- }
- cout<<min(a, b)<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement