hiho week 164 register

Ended

Participants:394

Verdict:Accepted
Score:100 / 100
Submitted:2017-08-26 13:58:11

Lang:G++

Edit
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
#include<iostream>
#include<string>
using namespace std;
int t;
int main(){
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int x0=0,x1=0,res=s.size();
        for(int i=0;i<s.size();i++){
            if(s[i]=='1'){
                x1=min(x0,x1);
                x0++;
                res=min(x1,x0);
            }
            else{
                x1=min(x0,x1)+1;
                res=min(x1,x0);
            }
        }
        cout<<res<<endl;
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX