#L. 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
ShanghaiTech ACM 炸鱼杯
- 状态
- 已结束
- 规则
- OI
- 题目
- 46
- 开始于
- 2024-12-10 23:00
- 结束于
- 2024-12-15 13:00
- 持续时间
- 110 小时
- 主持人
- 参赛人数
- 112