Sequence and Easy Queries
InterviewTime limit2sMemory limit1024 MB
With point updates on an array, count the maximal runs of equal adjacent values inside each queried subarray.
- Level
Medium4 of 10
- Topics
- Array, Prefix sum
- Solved
- No attempts yet
Problem
A contiguous subarray of a sequence is called a contiguous matching interval when all of its elements are equal. Such an interval is a contiguous matching interval of . An interval of is called an important contiguous matching interval if it is not fully contained in any other contiguous matching interval of .
You are given a sequence indexed from 1 and must answer queries.
1 i x: set to . ()2 l r: let be the contiguous subsequence . Print the number of distinct important contiguous matching intervals of . ()
This is not a hard problem, is it? I hope it does not feel hard to you either.
Input
The first line contains two integers and , separated by a space. ()
The second line contains the elements of the sequence, separated by spaces. ()
Each of the next lines contains one query. Each query is one of the types described in the problem.
The last query in every input is guaranteed to be of type 2.
Output
For each query of type 2, print the answer on its own line.