2016年武汉科技大学邀请赛网络赛 G题
来源:互联网 发布:南木梁知 编辑:程序博客网 时间:2024/04/30 13:27
Eliminating Fun
Time Limit: 10 Sec Memory Limit: 128 MB 64bit IO Format: %lldSubmitted: 61 Accepted: 9
[Submit][Status][Web Board]
Description
Q is busy hunting for jobs, resulting in that he can't solve algorithmic problem quickly. Bu Recenly ZZ have a easy problem, Xiao Q wants to help, But Xiao Q can’t solve it too, so can you solve it!
Give you a string, if you find adjacent characters are both '.', then you could cut one. You will have N operations:
X P -------- Replace the Xth character with P
How many dots do you have to cut so that there are no adjacent dots?
Input
Multiply test cases, terminate with EOF. The descriptions of the test cases follow:
Each testcase contains three parts, the first line contains two intergers L, N, the second line contains a string, the follow N lines contain X P in each line;
Note that the former operations will change our string. See the example for more information.
1 <= T <= 100, 1 <= L <= 100000, 1 <= N <= 100000, 1 <= X <= L .
Output
For each operation, output the answer in one line.
Sample Input
16 3B...DDDTen...ENT3 B10 .16 .
Sample Output
233
HINT
Huge input, recommend scanf rather than cin.
题目意思:给出一组字符串,然后给出进行的操作,这里每一步的操作都是建立在上一层操作后的结果上的,也就是说你上一层弄错了后面就全错。问操作完了之后最少需要去掉几个点使得字符串里面没有连续的两个点。
题解:对于每个操作,仅判断是增加了连续点区间还是合并了连续点区间即可,然后最小操作数是点数减区间数。
为什么这么做呢,比如X个点Y个区间,X-Y,本事就一个点的区间消失了,剩下的就是多余一个点的区间,这个情况下剩下的每个点都需要消去,因为最后每个点都代表一个区间明所以X-Y可以得到答案。
(这个做题的时候真的没想到这么做)
- 2016年武汉科技大学邀请赛网络赛 G题
- 2016年武汉科技大学邀请赛网络赛 A题
- 2016年武汉科技大学邀请赛网络赛 B题
- 2016年武汉科技大学邀请赛网络赛 J题
- 2016年武汉科技大学邀请赛网络赛 D题
- 2016年武汉科技大学邀请赛网络赛 C题
- 2016年武汉科技大学邀请赛网络赛 E题
- 2016年武汉科技大学邀请赛网络赛 F题
- 2016年武汉科技大学邀请赛网络赛 H题
- 2016年武汉科技大学邀请赛网络赛 I题
- 2016武汉科技大学邀请赛现场赛 G题
- 2016武汉科技大学邀请赛现场赛 A题
- 2016武汉科技大学邀请赛现场赛 B题
- 2016武汉科技大学邀请赛现场赛 C题
- 2016武汉科技大学邀请赛现场赛 D题
- 2016武汉科技大学邀请赛现场赛 E题
- 2016武汉科技大学邀请赛现场赛 F题
- 2016武汉科技大学邀请赛现场赛 L
- URLConnection
- <html>table、th
- sdutoj 3363 数据结构实验之图论七:驴友计划
- PowerDsigner 15.1 对实体的属性增加域
- JAVA 中消息提示框
- 2016年武汉科技大学邀请赛网络赛 G题
- JBOSS配置+修改端口号+与Tomcat比较
- Notification通知栏通知
- JavaWeb学习总结(四)——服务器
- Android自定义URL使用Scheme方式唤起Activity或App
- C++ 11 Lambda表达式
- Eclipse创建java web工程
- IP协议的定义、IP地址的分类及特点
- Eclipse窗口总是在最前的解决办法