LLppdd likes strings
LLppdd's likes strings!
Time Limit: 1 s Memory Limit: 256 MB
题目背景
LLppdd 由于实在是太弱了,在 \(ION 2018\) 模拟十连测中成功获得了多次零分......
由于考试的时候太无聊了,他就把这些 \(0\) 串成了一个字符串。
然后 LLppdd 又发现全是 \(0\) 的串 \(0000000...000\) 不够优美,于是他在中间随机加了几个数字 \(1\) (比如 \(01110101001...010110\))。
最后,他突发奇想!要不我们把他们全部变成 \(1\)?
题目描述
LLppdd 会两种操作:
操作1:选择一段连续的数,将他们的顺序变成逆序。 \((1 \underline{001} 1 \rightarrow 1 \underline{100} 1)\)
操作2:选择一段连续的数,将他们全部取反。 \((0 变成 1, 1 变成 0)\)。\((1 \underline{001} 1 \rightarrow 1 \underline{110} 1)\)
当然,每种操作都要他对应的花费,我们假设操作一的花费为 \(x\), 操作二的花费为 \(y\)。他想知道将整个字符串变成全 \(1\) 串的最小花费是多少?
输入格式
输入一共有两行:
第一行三个正整数 \(n, x, y\),分别表示选择接下来输入的字符串的长度,操作一的花费,操作二的花费。
第二行是一个长度为 \(n\) 的 \(01\) 串。
输出格式
输出一共一行:
将原字符串改成全 \(1\) 串的最小花费。
输出样例1
3 1 2
000
输出样例1
2
输入样例2
5 1 10
01000
输出样例2
11
数据范围
\(30\%\)的数据保证\(1≤n≤3\)。
\(50\%\)的数据保证\(1≤n≤10\)。
\(80\%\)的数据保证\(1≤n≤500\)。
\(100\%\)的数据保证\(1≤n≤10000\)。
HINT
对于样例一,花 \(2\) 元将整个字符串进行取反就可以了。
对于样例二的具体操作如下:
$ «01000» → «10000» → «11111» $ 总共花费为 \(1+10=11\) 元。
LLppdd likes strings的更多相关文章
- Codeforces Beta Round #17 C. Balance DP
C. Balance 题目链接 http://codeforces.com/contest/17/problem/C 题面 Nick likes strings very much, he likes ...
- UESTC_How many good substrings CDOJ 1026
Icerain likes strings very much. Especially the strings only consist of 0 and 1,she call them easy s ...
- Codeforces Round #396 (Div. 2)
C. Mahmoud and a Message time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- HGOI20180817 (NOIP模拟Day1 task)
HGOI自测 初测:150=80+20+50 rank1~rank3(并列3个rank1,所以我是rank3 qwq) 今日分突然想简约 CF359A Table https://www.luogu. ...
- Codeforces Round #396 (Div. 2) C. Mahmoud and a Message dp
C. Mahmoud and a Message 题目连接: http://codeforces.com/contest/766/problem/C Description Mahmoud wrote ...
- Codeforces 766C - Mahmoud and a Message
C. Mahmoud and a Message time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Codeforces Round #396 (Div. 2) A,B,C,D,E
A. Mahmoud and Longest Uncommon Subsequence time limit per test 2 seconds memory limit per test 256 ...
- Codeforces 766C Mahmoud and a Message 2017-02-21 13:57 62人阅读 评论(0) 收藏
C. Mahmoud and a Message time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Codeforces Round #396 (Div. 2) A B C D 水 trick dp 并查集
A. Mahmoud and Longest Uncommon Subsequence time limit per test 2 seconds memory limit per test 256 ...
随机推荐
- python 类的私有属性和方法 (转载)
转载:http://www.runoob.com/python/python-object.html 类属性与方法 类的私有属性 __private_attrs:两个下划线开头,声明该属性为私有,不能 ...
- rsync之expect脚本shell
r_expect.sh: #!/bin/expect -f set timeout 30 #spawn rsync -avz --delete --exclude-from=exclude.list ...
- vue中引入了sass,又引入cssnano报错
"cssnano": { // preset: "advanced", autoprefixer: false, "postcss-zindex&qu ...
- BZOJ3398 牡牛和牝牛
隔板搞掉就行了 特么我什么时候感冒能好!QAQ.脑子都没有了QAQ. //Love and Freedom. #include<cstdio> #include<cstring> ...
- 洛谷P4331[BOI2004] sequence
博客复活? 这个题很模板啊.随便上个左偏树.之前第一遍写对了.然后今天翻出来又写了一遍发现了一个奇奇怪怪的问题. 对比如下 上面的是AC 下面的WA 真的是一个很蠢的问题...你TM堆顶都弹出来了,堆 ...
- JavaSE---JDK提供的命令行工具---javap
1.javap 1.1 javap是JDK自带的反解析工具: 1.2 作用:就是根据class字节码文件,反解析出 当前类 对应的code区(汇编指令).本地变量表.异常表和代码行偏移量映射 ...
- ISO C 字符串创建算符 “#”
使用用途: #define doit(name) pr_limits(#name, name) doit(RLIMIT_CORE); 这将由C预处理程序扩展为: pr_limits("RLI ...
- hdu 6146 Pokémon GO (计数)
Problem Description 众所周知,度度熊最近沉迷于 Pokémon GO. 今天它决定要抓住所有的精灵球!为了不让度度熊失望,精灵球已经被事先放置在一个2*N的格子上,每一个格子上都有 ...
- DIV 粘贴插入文本或者其他元素后,移动光标到最新处
此文主要是可编辑div光标位置处理 1:首先 设置一个可编辑的DIV,注意:设置 contenteditable="true" 才可以编辑DIV <div id=" ...
- signer information does not match signer information of other classes in the same package
报错日志: java.lang.SecurityException: class "org.bouncycastle.asn1.ASN1ObjectIdentifier"'s si ...