Shifting
Statement
You are given an array of N integers in and array A, you are supposed to do 3 different type of operations:
if the query is 1 i j
Shift the numbers in the array from Ai to Aj inclusive to the front
if the query is 2 i j
Shift the numbers in the array from Ai to Aj inclusive to the back
if the query is 0 i
Output the number at position i, 0-indexed
Input
First line contain 2 integers, N and Q;
Second line contains N integers of the array
Subsequent lines contain T, i, j. T is the query type
Output
If T is 0, output the number at that position, 0-indexed
Scoring
Subtask 1 (5%): N,Q <= 1000
Subtask 2 (15%): N,Q <= 10000
Subtask 3 (69%): N,Q <= 100000
Subtask 4 (11%): N,Q <= 500000
0 <= Ai <= 1000000000 (10^9)
0 <= i <= j < N
T = 0,1,2