题库练习 Grime Zoo
← 上一题 下一题 →

A13684 | Grime Zoo

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Currently, XXOC's rap is a string consisting of zeroes, ones, and question marks. Unfortunately, haters gonna hate. They will write $x$ angry comments for every occurrence of subsequence 01 and $y$ angry comments for every occurrence of subsequence 10. You should replace all the question marks with 0 or 1 in such a way that the number of angry comments would be as small as possible.

String $b$ is a subsequence of string $a$ , if it can be obtained by removing some characters from $a$ . Two occurrences of a subsequence are considered distinct if sets of positions of remaining characters are distinct.

输入格式

The first line contains string $s$ — XXOC's rap ( $1 \le |s| \leq 10^5$ ). The second line contains two integers $x$ and $y$ — the number of angry comments XXOC will recieve for every occurrence of 01 and 10 accordingly ( $0 \leq x, y \leq 10^6$ ).

输出格式

Output a single integer — the minimum number of angry comments.

输入输出样例

输入 #1
0?1
2 3
输出 #1
4
输入 #2
?????
13 37
输出 #2
0
输入 #3
?10?
239 7
输出 #3
28
输入 #4
01101001
5 7
输出 #4
96
C++ 编辑器
输入
输出