CF911D.Inversion Counting

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A permutation of size nn is an array of size nn such that each integer from 11 to nn occurs exactly once in this array. An inversion in a permutation pp is a pair of indices (i,j)(i,j) such that i>ji>j and ai<aja_{i}<a_{j} . For example, a permutation [4,1,3,2][4,1,3,2] contains 44 inversions: (2,1)(2,1) , (3,1)(3,1) , (4,1)(4,1) , (4,3)(4,3) .

You are given a permutation aa of size nn and mm queries to it. Each query is represented by two indices ll and rr denoting that you have to reverse the segment [l,r][l,r] of the permutation. For example, if a=[1,2,3,4]a=[1,2,3,4] and a query l=2l=2 , r=4r=4 is applied, then the resulting permutation is [1,4,3,2][1,4,3,2] .

After each query you have to determine whether the number of inversions is odd or even.

输入格式

The first line contains one integer nn ( 1<=n<=15001<=n<=1500 ) — the size of the permutation.

The second line contains nn integers a1a_{1} , a2a_{2} , ..., ana_{n} ( 1<=ai<=n1<=a_{i}<=n ) — the elements of the permutation. These integers are pairwise distinct.

The third line contains one integer mm ( 1<=m<=21051<=m<=2·10^{5} ) — the number of queries to process.

Then mm lines follow, ii -th line containing two integers lil_{i} , rir_{i} ( 1<=li<=ri<=n1<=l_{i}<=r_{i}<=n ) denoting that ii -th query is to reverse a segment [li,ri][l_{i},r_{i}] of the permutation. All queries are performed one after another.

输出格式

Print mm lines. ii -th of them must be equal to odd if the number of inversions in the permutation after ii -th query is odd, and even otherwise.

输入输出样例

  • 输入#1

    3
    1 2 3
    2
    1 2
    2 3
    

    输出#1

    odd
    even
    
  • 输入#2

    4
    1 2 4 3
    4
    1 1
    1 4
    1 4
    2 3
    

    输出#2

    odd
    odd
    odd
    even
    

说明/提示

The first example:

  1. after the first query a=[2,1,3]a=[2,1,3] , inversion: (2,1)(2,1) ;
  2. after the second query a=[2,3,1]a=[2,3,1] , inversions: (3,1)(3,1) , (3,2)(3,2) .

The second example:

  1. a=[1,2,4,3]a=[1,2,4,3] , inversion: (4,3)(4,3) ;
  2. a=[3,4,2,1]a=[3,4,2,1] , inversions: (3,1)(3,1) , (4,1)(4,1) , (3,2)(3,2) , (4,2)(4,2) , (4,3)(4,3) ;
  3. a=[1,2,4,3]a=[1,2,4,3] , inversion: (4,3)(4,3) ;
  4. a=[1,4,2,3]a=[1,4,2,3] , inversions: (3,2)(3,2) , (4,2)(4,2) .
首页