hzau 1207 Candies
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的更多相关文章
- HZAU 1207 Candies(线段树区间查询 区间修改)
[题目链接]http://acm.hzau.edu.cn/problem.php?id=1207 [题意]给你一个字符串,然后两种操作:1,将区间L,R更新为A或者B,2,询问区间L,R最长的连续的B ...
- 【POJ2886】Who Gets the Most Candies?-线段树+反素数
Time Limit: 5000MS Memory Limit: 131072K Case Time Limit: 2000MS Description N children are sitting ...
- poj 3159 Candies 差分约束
Candies Time Limit: 1500MS Memory Limit: 131072K Total Submissions: 22177 Accepted: 5936 Descrip ...
- Who Gets the Most Candies?(线段树 + 反素数 )
Who Gets the Most Candies? Time Limit:5000MS Memory Limit:131072KB 64bit IO Format:%I64d &am ...
- poj---(2886)Who Gets the Most Candies?(线段树+数论)
Who Gets the Most Candies? Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 10373 Acc ...
- poj3159 Candies(差分约束,dij+heap)
poj3159 Candies 这题实质为裸的差分约束. 先看最短路模型:若d[v] >= d[u] + w, 则连边u->v,之后就变成了d[v] <= d[u] + w , 即d ...
- HDU 5127 Dogs' Candies
Dogs' Candies Time Limit: 30000/30000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) T ...
- C. Om Nom and Candies 巧妙优化枚举,将复杂度控制在10e6
C. Om Nom and Candies 无线超大背包问题 #include <iostream> #include <cstdio> #include <cstrin ...
- POJ 3159 Candies (栈优化spfa)
Candies 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/J Description During the kinderga ...
随机推荐
- 前端基础 & 初识CSS
CSS介绍 CSS(Cascading Style Sheet,层叠样式表)定义如何显示HTML元素.l 当浏览器读到一个样式表,它就会按照这个样式表来对文档进行格式化(渲染). CSS语法 每个CS ...
- python基础——函数参数
课上老师已经讲过函数(func)的参数(args)传递. 之前学习了根据位置传递对应的参数,下面会介绍其他参数传递方式. 之前的位置传参: def f(a,b,c): return a+b+c pri ...
- python面试题(三)
1 一行代码实现9*9乘法表 print ("\n".join("\t".join(["%s*%s=%s" %(x,y,x*y) for y ...
- 磁盘对齐-windows篇
什么是磁盘分区对齐(Disk Alignment.Partition Alignment): Windows的磁盘有一种结构叫做Master Boot Record(MBR), 它的默认大小为63个B ...
- rar 7z文件打包
把D:\file目录下的所有东西打包为file.rar放到D:\目录下, Rar.exe是放在c盘根目录下 >>C:\Rar.exe a -k -r -s -m1 D:\file.rar ...
- VIMTUTOR 1.7中文版
文章来源:http://waterxfire.blog.hexun.com/4106986_d.html =============================================== ...
- python read文件的r和rb的区别
r,rb,w,wb 那么在读写文件时,有无b标识的的主要区别在哪里呢? 1.文件使用方式标识 'r':默认值,表示从文件读取数据. 'w':表示要向文件写入数据,并截断以前的内容 'a':表示要向文件 ...
- JAVA项目中常用的异常知识点总结
JAVA项目中常用的异常知识点总结 1. java.lang.nullpointerexception这个异常大家肯定都经常遇到,异常的解释是"程序遇上了空指针",简单地说就是调用 ...
- Django Rest Framework(一)
一.什么是RESTful REST与技术无关,代表一种软件架构风格,REST是Representational State Transfer的简称,中文翻译为“表征状态转移”. REST从资源的角度审 ...
- Loadrunner脚本篇——从文件中读取内容并参数化
直接代码展示: char* testfn() { int count, total = 0; char * buffer = NULL; int filelenth = 0; long file_st ...