Sequence and Queries 35
Time limit7sMemory limit512 MB
Given a permutation, each query rotates a subarray right by k positions, then asks whether the array has an increasing subsequence of length 3.
- Level
Hard8 of 10
- Topics
- Segment tree, Array, Implementation
- Solved
- No attempts yet
Problem
A sequence of length is given. Every number in the sequence is between and inclusive, and all numbers are distinct. Write a program that processes the following query.
l r k: Shift the subarray right by positions. That is, becomes , becomes , becomes , and becomes . After the shift, printYESif the sequence contains an increasing subsequence of length 3, andNOotherwise.
Input
The first line contains the size of the sequence. ()
The second line contains . All numbers are distinct. ()
The third line contains the number of queries . ()
The next lines each contain one query. (, )
Output
Print the result of each query on its own line.