Akku and Arrays
Medium Accuracy: 25.34% Submissions: 676 Points: 4

Akku have solved many problems, she is genius. One day her friend gave her an Array and asked her to perform
some queries of following type:
Each query consists of three integers
1 A B : Update the Array at index A by value B
2 A B : if the subarray from index A to B (both inclusive) is
        1. Both increasing(Non-decreasing) and decreasing(Non-increasing) print -1
        2. Only increasing(Non-decreasing) print 0
        3. Only decreasing(Non-increasing) print 1
        4. Neither increasing nor decreasing print -1

Akku needs your help, can you help her.

Input:
The first line of input constists of the integer T, indicating the number of test cases.The first line of each
test case constists of the number N, indicating the number of elements in the array,A. Next line consists of N space
seperated integers indicating the array. Next line consists of an integer Q , denoting the
number of queries. Next Q lines consists of three integers X,A,B

Output:
For each test case query of type 2, the output is an integer indicating the required Answer in newline.

Constraints:
1 <= T <= 5
1 <= N <= 100000
1 <= A[i] <= 100000
1 <= Q <= 100000

Example:
Input:

1
7
1 5 7 4 3 5 2
5
2 1 3
2 2 4
2 3 4
1 6 3
2 5 6
Output:
0
-1
1
-1

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.