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 ...
随机推荐
- Django组件——用户认证
用户认证 一.auth模块 from django.contrib import auth django.contrib.auth中提供了许多方法,这里主要介绍其中的三个: 1 .authentica ...
- ltp-ddt eth_iperf_tcp iperf dualtest遇到的问题
ltp-ddt eth_iperf_tcp server端:iperf -s -i 5 -w 1M client端将ddt的核心代码抠出来: iperf -c 1921.68.40.41 -m -M ...
- SpringBoot中发送邮件服务
.转载:http://www.ityouknow.com/springboot/2017/05/06/spring-boot-mail.html 简单使用 1.pom 包配置 <dependen ...
- vue之templete模板
1.templete里要用data里的数据的话,不要加this. 2.按理说Js是写在<script></script>标签体内的.但是Vue的templete模板中对所有的数 ...
- SDOI前的小计划
upd:19.4.5 放出来了.如果明天考了我没复习到的认了.考到了复习了的还没拿到理想分的就回来谢罪(bushi www SDOI一轮倒计时4天啦w 所以得有个小计划吧QwQ 4.2 目标:BZOJ ...
- equals区别==
来自:https://blog.csdn.net/m0_37721946/article/details/78405595 java中的数据类型,可分为两类: 1.基本数据类型 byte,short, ...
- vue-葵花宝典
router-view 中包含 router-view 这种情况就可以 使用嵌套路由了 变化的视图中包含变化的视图 代码层面 router-view 中 包含router-view 路由childre ...
- 在Android中实现一个简易的Http服务器
最近遇到一个需求需要在App中创建一个Http服务器供供浏览器调用,用了下开源的微型Htpp服务器框架:NanoHttpd,项目地址:https://github.com/NanoHttpd/nano ...
- 09-排序2 Insert or Merge(25 分)
According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and gr ...
- 【LeetCode 90】子集 II
题目链接 [题解] 我们在枚举下一个要取哪个数字的时候. 如 1112233 for (int i = start;i<=n;i++) //其中start-1是上一次取的位置. 如果i>s ...