CF911D

题解:

简单的奇偶判断

代码:

#include
using namespace std;
const int N=1505;
int n,a[N],ans,m,p,q;
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)scanf("%d",&a[i]);
    for (int i=1;i<=n;i++)
     for (int j=i+1;j<=n;j++)
      if (a[i]>a[j])ans^=1;
    scanf("%d",&m);
    while (m--)
     {
         scanf("%d%d",&p,&q);
         if ((q-p+1)*(q-p)/2%2)ans^=1;
         if (ans)puts("odd");
         else puts("even");
     }   
}

 

转载于:https://www.cnblogs.com/xuanyiming/p/8178263.html

你可能感兴趣的:(CF911D)