Problem A
0-1 Sequences
You are given a sequence, in the form of a string with
characters ‘0’, ‘1’, and ‘?’ only.
Suppose there are
For each 0-1 sequence, define its number of inversions as
the minimum number of adjacent swaps required to sort the
sequence in non-decreasing order. In this problem, the sequence
is sorted in non-decreasing order precisely when all the zeroes
occur before all the ones. For example, the sequence 11010 has
Find the sum of the number of inversions of the
Input
The first and only line of input contains the input string,
consisting of characters ‘0’,
‘1’, and ‘?’ only, and the input string has between
Output
Output an integer indicating the aforementioned number of
inversions modulo
Sample Input 1 | Sample Output 1 |
---|---|
?0? |
3 |