#UnknownID12. JIXMPII5JUgT100#-`]
JIXMPII5JUgT100#-`]
Statement
Let's define a cyclic shift of some string as a transformation from into . In other words, you take one last character and place it before the first character while moving all other characters to the right.
You are given a binary string (a string consisting of only 0-s and/or 1-s).
In one operation, you can choose any substring ( ) and cyclically shift it. The cost of such operation is equal to (or the length of the chosen substring).
You can perform the given operation any number of times. What is the minimum total cost to make sorted in non-descending order?
Format
Input
The first line contains a single integer ( ) — the number of test cases.
The first and only line of each test case contains a binary string ( ; {0, 1}) — the string you need to sort.
Additional constraint on the input: the sum of lengths of strings over all test cases doesn't exceed .
Output
For each test case, print the single integer — the minimum total cost to make string sorted using operation above any number of times.
Sample
5
10
0000
11000
101011
01101001
2
0
9
5
11
相关
在下列比赛中: