-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path646B.cpp
More file actions
33 lines (31 loc) · 677 Bytes
/
Copy path646B.cpp
File metadata and controls
33 lines (31 loc) · 677 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
string s;
cin >> s;
bool one = false,zero = false;
int cnt1 = 0,cnt0 = 0;
for (int i = 0; i < s.size(); i++)
{
if(s[i]=='1' &&!one){
one = true;
}
else if(s[i]=='0' && !zero){
zero = true;
}
if(s[i]=='1' && zero){
cnt1++;
}
else if(s[i]=='0' && one){
cnt0++;
}
}
int ans = min(cnt1, cnt0);
printf("%d\n",ans);
}
}