401824: GYM100534 G Coin Game
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
G. Coin Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
Alice and Bob are very smart guys and they like to play all kinds of games in their spare time. The most amazing thing is that they always find the best strategy, and that's why they feel bored again and again. They just invented a new game, as they usually did. They are playing with coins. They have a row of $1 and $2 coins. They want to change this row so that all $1's are grouped together and all $2's are grouped together. They are just allowed to swap two neighbor coins. Using the best strategy what is the minimum number of swaps required to do this task?
InputEach test case is a line with a string composed of 1 and 2. (1 ≤ length of the input string ≤ 25000)
OutputPrint the minimum number of swaps required to do this task.
ExamplesInput221212Output
3