#abc322f. F - Vacation Query
F - Vacation Query
Score : points
问题描述
你得到一个长度为 的字符串 ,由 0
和 1
组成。令 表示 中的第 个字符。
按照给定顺序处理 个查询操作。每个查询由一个包含三个整数的元组 表示,其中 表示查询的类型。
- 当 时:对于满足 的每个整数 ,如果 是
1
,将其改为0
;如果它是0
,则将其改为1
。 - 当 时:获取从第 个到第 个字符组成的子字符串 。输出 中连续
1
s 的最大数量。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a string of length consisting of 0
and 1
. Let denote the -th character of .
Process queries in the order they are given.
Each query is represented by a tuple of three integers , where represents the type of the query.
- When : For each integer such that , if is
1
, change it to0
; if it is0
, change it to1
. - When : Let be the string obtained by extracting the -th through -th characters of . Print the maximum number of consecutive
1
s in .
Constraints
- is a string of length consisting of
0
and1
. - , , , , and are all integers.
Input
The input is given from Standard Input in the following format, where represents the -th query:
Each query is given in the following format:
Output
Let be the number of queries with . Print lines.
The -th line should contain the answer to the -th query with .
Sample Input 1
7 6
1101110
2 1 7
2 2 4
1 3 6
2 5 6
1 4 7
2 1 7
Sample Output 1
3
1
0
7
The queries are processed as follows.
- Initially,
1101110
. - For the first query,
1101110
. The longest sequence of consecutive1
s in is111
from the -th character to -th character, so the answer is . - For the second query,
101
. The longest sequence of consecutive1
s in is1
at the -st or -rd character, so the answer is . - For the third query, the operation changes to
1110000
. - For the fourth query,
00
. does not contain1
, so the answer is . - For the fifth query, the operation changes to
1111111
. - For the sixth query,
1111111
. The longest sequence of consecutive1
s in is1111111
from the -st to -th characters, so the answer is .
update @ 2024/3/10 01:43:09