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

时间: 2024-10-13 12:41:45

hzau 1207 Candies的相关文章

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

[题目链接]http://acm.hzau.edu.cn/problem.php?id=1207 [题意]给你一个字符串,然后两种操作:1,将区间L,R更新为A或者B,2,询问区间L,R最长的连续的B为多长. [分析]典型线段树,每个节点维护该区间左边连续B的长度,右边连续B的长度,最长的连续B的长度,还有lazy标记. #include <cstdio> #include <cstring> #include <iostream> #include <algor

hdu 1207 汉诺塔II (DP+递推)

汉诺塔II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4529    Accepted Submission(s): 2231 Problem Description 经典的汉诺塔问题经常作为一个递归的经典例题存在.可能有人并不知道汉诺塔问题的典故.汉诺塔来源于印度传说的一个故事,上帝创造世界时作了三根金刚石柱子,在一根柱子上从下往

poj 3159 Candies

题目链接:http://poj.org/problem?id=3159 Candies Time Limit: 1500MS   Memory Limit: 131072K Total Submissions: 22516   Accepted: 6047 Description During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought th

LeetCode解题思路:575. Distribute Candies

Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these candies equally in number to brother and sister.

计算次数,POJ(1207)

题目链接:http://poj.org/problem?id=1207 #include <stdio.h> #include <algorithm> using namespace std; int i,j; int Max; int fun(int k) { int Count=1; while(k!=1) { if(k%2==1) k=k*3+1; else k/=2; Count++; } return Count; } int main() { while(scanf(&

poj3159 Candies(差分约束)

转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Candies Time Limit: 1500MS   Memory Limit: 131072K Description During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’

poj 2886 Who Gets the Most Candies? (线段树单点更新应用)

poj 2886 Who Gets the Most Candies? Description N children are sitting in a circle to play a game. The children are numbered from 1 to N in clockwise order. Each of them has a card with a non-zero integer on it in his/her hand. The game starts from t

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

Who Gets the Most Candies? Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 10373   Accepted: 3224 Case Time Limit: 2000MS Description N children are sitting in a circle to play a game. The children are numbered from 1 to N in clockwise

poj 2886 Who Gets the Most Candies?(线段树+约瑟夫环+反素数)

Who Gets the Most Candies? Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 9934   Accepted: 3050 Case Time Limit: 2000MS Description N children are sitting in a circle to play a game. The children are numbered from 1 to N in clockwise o