Mascot Song
InterviewTime limit1sMemory limit32 MB
Maintain an array under point updates and left rotations, reporting the number of maximal strictly increasing runs after each query.
- Level
Medium6 of 10
- Topics
- Array, Simulation
- Solved
- No attempts yet
Problem
Fuleco writes a song as a sequence . A consecutive subarray () is a block when:
- or
- or
Every element belongs to exactly one block.
You get the starting sequence and queries:
1 x y: set2 z: rotate the whole sequence left by (the first element wraps to the end)
After each query, print the current number of blocks.
Input
Line 1: .
Line 2: .
Line 3: .
Next lines: queries (1 x y or 2 z).
Output
Print the block count after each query, one per line in order.
Constraints
, , .