1207: Candies

Time Limit: 2 Sec  Memory Limit: 1280 MB
Submit: 223  Solved: 31
[Submit][Status][Web Board]

Description

Xiao Ming likes those N candies he collects very much. There are two kinds of candies, A and B. One day, Xiao Ming puts his candies in a row and plays games. And he can replace the Lth candy to the Rth candy with the same kind of candies. Now, he wonder that if he eats the Lth candy to Rth candy, he can eat how many B candy continuously at most. For each Xiao Ming’s query, give the number of the B candy he can eat continuously at most.

Input

In the first line, there is an integer T, indicates the number of test cases.

For each case, there are two integers N and M in the first line, indicate the number of candies and the time of Xiao Ming’s operations.

The second line is a N-length string consist of character A and B, indicates the row of candies Xiao Ming put.

The next M line is Xiao Ming’s operations. There are two kind of operations:

1. 1 L R v, indicate Xiao Ming replaces the Lth candy to the Rth candy with A candies (v==1) or B candies ( v == 2 ).

2. 2 L R, indicate Xiao Ming wonder that there are how many continuous B candies between the Lth candy to the Rth candy most.

Output

In each case, the first line is “Case #k: “, k indicates the case number.

For each query, output the number of the most continuous B candies.

Sample Input

1
5 3
ABABB
2 1 3
1 2 3 2
2 1 3

Sample Output

Case #1:
1
2

HINT

hzau 1207 Candies的更多相关文章

  1. HZAU 1207 Candies(线段树区间查询 区间修改)

    [题目链接]http://acm.hzau.edu.cn/problem.php?id=1207 [题意]给你一个字符串,然后两种操作:1,将区间L,R更新为A或者B,2,询问区间L,R最长的连续的B ...

  2. 【POJ2886】Who Gets the Most Candies?-线段树+反素数

    Time Limit: 5000MS Memory Limit: 131072K Case Time Limit: 2000MS Description N children are sitting ...

  3. poj 3159 Candies 差分约束

    Candies Time Limit: 1500MS   Memory Limit: 131072K Total Submissions: 22177   Accepted: 5936 Descrip ...

  4. Who Gets the Most Candies?(线段树 + 反素数 )

    Who Gets the Most Candies? Time Limit:5000MS     Memory Limit:131072KB     64bit IO Format:%I64d &am ...

  5. poj---(2886)Who Gets the Most Candies?(线段树+数论)

    Who Gets the Most Candies? Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 10373   Acc ...

  6. poj3159 Candies(差分约束,dij+heap)

    poj3159 Candies 这题实质为裸的差分约束. 先看最短路模型:若d[v] >= d[u] + w, 则连边u->v,之后就变成了d[v] <= d[u] + w , 即d ...

  7. HDU 5127 Dogs' Candies

    Dogs' Candies Time Limit: 30000/30000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) T ...

  8. C. Om Nom and Candies 巧妙优化枚举,将复杂度控制在10e6

    C. Om Nom and Candies 无线超大背包问题 #include <iostream> #include <cstdio> #include <cstrin ...

  9. POJ 3159 Candies (栈优化spfa)

    Candies 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/J Description During the kinderga ...

随机推荐

  1. Oracle ErrorStack 使用和阅读具体解释

    一.概述 在Oracle数据库执行过程中,我们常常会遇到这样或那样的错误.可是错误的提示并不详细,加大了我们在诊断问题时的难度. ErrorStack是Oracle提供的一种对于错误堆栈进行跟踪的方法 ...

  2. git原理:引用规格

    引用规格(refspec):就是在 .git/config 里面那个配置远程仓库的东西 [remote "origin"]url = https://github.com/test ...

  3. Python lxml 使用

    lxml,是python中用来处理xml和html的功能最丰富和易用的库 from lxml import etree from lxml import html h = ''' <html&g ...

  4. docker daemon.json 配置

    下面是自己设置的 /etc/docker/daemon.json 文件中的配置案例 [root@master docker]# cat daemon.json { "registry-mir ...

  5. $《第一行代码:Android》读书笔记——第1章 Android系统

    (一)Android系统架构 1.Linux内核层:各种底层驱动,如显示驱动.音频驱动.电源管理等. 2.系统运行库层:各种库支持,如3D绘图.浏览器内核.数据库等. 3.应用框架层:各种API,各种 ...

  6. 011_用eclipse打开hadoop1.2.1源码出现The method getSplits(JobConf, int) is undefined for the type Object错误

    出现的错误截图: 此时Eclipse使用的jdk1.8,将编译环境改成jdk1.7就行了,解决. 没问题了. 下面观点是参考如下网址,未经验证.参考:http://blog.csdn.net/onei ...

  7. Keepalived 主备配置

    keepalived主备或多主多备,配置都是一样配置方法,只是搭建多少的问题. 1.keepalived安装 参考:https://www.cnblogs.com/zwcry/p/9542867.ht ...

  8. tcp/ip 中的分组和分片

    osi 大家应该都知道osi七层模型吧,物理层 链路层 网络层 传输层 会话层 表示层 应用层ip 属于网络层,tcp 属于传输层,你可以把每一层想像成粽子的粽叶,包裹了七层的粽子最外面的就是物理层, ...

  9. Docker容器技术-命令进阶

    一.基本命令 1.Docker布尔型选项 使用某选项但没有提供参数,等同于把选项设置为true,要改变它的值,唯一的方法是将其设置成false. 找出一个选项的默认值是true还是false: [ro ...

  10. Xib与Storyboard相关知识点

    相同点 都用来描述软件界面 都用Interface Builder工具来编辑 本质都是转换成代码去创建控件 不同点 Xib是轻量级的,用来描述局部的UI界面 Storyboard是重量级的,用来描述整 ...