CF1411D.Grime Zoo
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
目前,XXOC 的说唱是一段由数字 0、1 和问号 ? 组成的字符串。不幸的是,黑粉总会黑你。对于每一个子序列 01 的出现,他们会留下 x 条愤怒评论;对于每一个子序列 10 的出现,他们会留下 y 条愤怒评论。你需要将所有问号 ? 替换为 0 或 1,使得愤怒评论的总数尽可能少。
若字符串 b 可通过从字符串 a 中删除若干字符得到,则称 b 是 a 的一个子序列。若两个子序列出现所对应保留字符的位置集合不同,则认为它们是两个不同的出现。
输入格式
The first line contains string s — XXOC's rap (1≤∣s∣≤105). 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≤x,y≤106).
第一行包含字符串 s — XXOC 的说唱内容(1≤∣s∣≤105)。第二行包含两个整数 x 和 y — 分别表示每出现一次子串 01 和 10 时,XXOC 将收到的愤怒评论数(0≤x,y≤106)。
输出格式
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
说明/提示
In the first example one of the optimum ways to replace is 001. Then there will be 2 subsequences 01 and 0 subsequences 10. Total number of angry comments will be equal to 2⋅2+0⋅3=4.
In the second example one of the optimum ways to replace is 11111. Then there will be 0 subsequences 01 and 0 subsequences 10. Total number of angry comments will be equal to 0⋅13+0⋅37=0.
In the third example one of the optimum ways to replace is 1100. Then there will be 0 subsequences 01 and 4 subsequences 10. Total number of angry comments will be equal to 0⋅239+4⋅7=28.
In the fourth example one of the optimum ways to replace is 01101001. Then there will be 8 subsequences 01 and 8 subsequences 10. Total number of angry comments will be equal to 8⋅5+8⋅7=96.
在第一个例子中,一种最优的替换方式是 001。此时将有 2 个子序列 01 和 0 个子序列 10。愤怒评论的总数为 2⋅2+0⋅3=4。
在第二个例子中,一种最优的替换方式是 11111。此时将有 0 个子序列 01 和 0 个子序列 10。愤怒评论的总数为 0⋅13+0⋅37=0。
在第三个例子中,一种最优的替换方式是 1100。此时将有 0 个子序列 01 和 4 个子序列 10。愤怒评论的总数为 0⋅239+4⋅7=28。
在第四个例子中,一种最优的替换方式是 01101001。此时将有 8 个子序列 01 和 8 个子序列 10。愤怒评论的总数为 8⋅5+8⋅7=96。
输入解题思路,AI测评打分。不知道怎么写?