Permutations and Features

0

0 votes
Hard
Problem

STATEMENT

Definitions:
Permutation of length N– sequence of size N which contains all integers from 1 to N.
Feature- A pair of index (a,b) is said to be the feature if a>b and Aa<Ab.

Given a permutation of length N and Q queries. Each query contains two integers l,r. You need to reverse the segment [l,r] and then check whether the number of features in the permutation is odd or even.

INPUT

The first line contains single integer N.
The second line contains the permutation in the form of A1 A2 A3…An.
The third line contains single integer Q, number of queries.
Each query contains two space separated integers l and r, as described above.

OUTPUT

For each query print either odd or even, as described above.

CONSTRAINTS

1<=N<=2000
1<=Q<=105
1<=L<=R<=N

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

After the first query the permutation is {2,3,1,4} , so there are 2 features, i.e. (3,1) and (3,2).
After the second query the permutation becomes {2,4,1,3}, so there are 3 features, i.e. (3,1),(3,2) and (4,2).

Editor Image

?