YouKn0wWho has an integer sequence a1,a2,…ana1,a2,…an. Now he will split the sequence aa into one or more consecutive subarrays so that each element of aa belongs to exactly one subarray. Let kk be the number of resulting subarrays, and h1,h2,…,hkh1,h2,…,hk be the lengths of the longest increasing subsequences of corresponding subarrays.

For example, if we split [2,5,3,1,4,3,2,2,5,1][2,5,3,1,4,3,2,2,5,1] into [2,5,3,1,4][2,5,3,1,4], [3,2,2,5][3,2,2,5], [1][1], then h=[3,2,1]h=[3,2,1].

YouKn0wWho wonders if it is possible to split the sequence aa in such a way that the bitwise XOR of h1,h2,…,hkh1,h2,…,hk is equal to 00. You have to tell whether it is possible.

The longest increasing subsequence (LIS) of a sequence b1,b2,…,bmb1,b2,…,bm is the longest sequence of valid indices i1,i2,…,iki1,i2,…,ik such that i1<i2<…<iki1<i2<…<ik and bi1<bi2<…<bikbi1<bi2<…<bik. For example, the LIS of [2,5,3,3,5][2,5,3,3,5] is [2,3,5][2,3,5], which has length 33.

An array cc is a subarray of an array bb if cc can be obtained from bb by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

Input

The first line contains a single integer tt (1≤t≤100001≤t≤10000)  — the number of test cases.

The first line of each test case contains a single integer nn (2≤n≤1052≤n≤105).

The second line of each test case contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1091≤ai≤109).

It is guaranteed that the sum of nn over all test cases doesn't exceed 3⋅1053⋅105.

Output

For each test case, print "YES" (without quotes) if it is possible to split into subarrays in the desired way, print "NO" (without quotes) otherwise. You can print each letter in any register (upper or lower).

Example

input

Copy

4
7
1 3 4 2 2 1 5
3
1 3 4
5
1 3 2 4 2
4
4 3 2 1

output

Copy

YES
NO
YES
YES

Note

In the first test case, YouKn0wWho can split the sequence in the following way: [1,3,4][1,3,4], [2,2][2,2], [1,5][1,5]. This way, the LIS lengths are h=[3,1,2]h=[3,1,2], and the bitwise XOR of the LIS lengths is 3⊕1⊕2=03⊕1⊕2=0.

In the second test case, it can be shown that it is impossible to split the sequence into subarrays that will satisfy the condition.

思路:要想异或为0那就可以令它们相等,这样异或就为0了。如何让它们相等呢?因为此时还需要考虑最大上升子序列,取的时候会非常麻烦,所以我们直接去1个,这样我们就不用考虑大小了。

此时就要分奇偶了,偶直接就能1异或1了,直接为0;开始考虑奇了,奇数不为1时就一定有3个能取(去掉偶数个),上升子序列最小也要是1,所得两个数抵消,三个数分成两个,就一定有一个是1,一个是2个,一的一定是1,那么2的也要是1,为1只有递减,所以就有了答案。

#include <iostream>using namespace std;int main()
{int t;cin>>t;while(t--){int n;cin>>n;int a[n];bool flag=false;if(n%2==0) flag=true;cin>>a[0];for(int i=1;i<n;i++){cin>>a[i];if(a[i]<=a[i-1]){flag=true;}}if(flag) cout<<"YES"<<endl;else cout<<"NO"<<endl;}return 0;
}

XOR Specia-LIS-t相关推荐

  1. xor和gates的专杀脚本

    前段时间的一次样本,需要给出专杀,应急中遇到的是linux中比较常见的两个家族gates和xor. 首先是xor的专杀脚本,xor样本查杀的时候需要注意的是样本的主进程和子进程相互保护(详见之前的xo ...

  2. ZSTU2019校赛 Problem D Lis(线性基dp)

    我的做题思路参考的是这位大佬(代码就把他的抄了一遍) https://blog.csdn.net/kzn2683331518/article/details/88768657 题面: 令LIS(S)为 ...

  3. 【按位异或】B. XOR Specia-LIS-t

    题目来源 Problem - B - Codeforceshttps://codeforces.com/contest/1604/problem/B 题干 官方思路 解释 当数列个数n为偶数时,我们可 ...

  4. UVa 10051 Tower of Cubes(类似LIS)

    题意: 一些重量递增而且各个面都有颜色的立方体,要将这些立方体堆成一个塔,要求两个接触面同色,而且下面的立方体更重.求塔的最大高度. 思路: 用求LIS的思想,无非是多了几个状态.dp[i][j]表示 ...

  5. 1045 Favorite Color Stripe(LIS解法)

    解题思路 本题属于Longest Increasing Sequence最长不下降子序列,但是要注意,LIS当中不会有无效的元素,而本题是有的,所以先要把无效元素过滤掉,才能转化成为LIS问题. 这里 ...

  6. LIS ZOJ - 4028

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4028 memset超时 这题竟然是一个差分约束 好吧呢 对于每一个a[i] ...

  7. 【hdu】4521 小明序列【LIS变种】【间隔至少为d】

    题目链接:https://vjudge.net/contest/228455#problem/B 转载于:https://blog.csdn.net/a709743744/article/detail ...

  8. HDU 1257 - 最少拦截系统 ( LIS / 贪心 )

    题目 现在有一种拦截系统,第一发拦截可以是任意高度,但是之后的拦截高度不能比上次高.为了拦截下所有的炮弹,最少需要准备几套拦截系统? 思路 可能是语文没学好吧,一开始被题意卡了一下.(而且题目连数据范 ...

  9. 【Codeforces/HDU】76A Plus and xor / 2095 find your present (2)(异或)。

    http://codeforces.com/contest/76/problem/D A = X + Y B = X xor Y 异或(不进位加法):两个二进制数,对应的位置上,相同为0,不同为1 性 ...

最新文章

  1. Nginx/LVS/HAProxy 负载均衡软件的优缺点详解
  2. 当云原生遇到混合云:如何实现“求变”与“求稳”的平衡
  3. objective-C CollectionView 加深(添加注册头部View)
  4. 不裁员也好意思叫互联网公司?
  5. tensorflow线性回归基础函数
  6. 黑马程序员——Java基础---String与StringBuilder
  7. 【机器学习】Andrew Ng——03线性代数知识回顾
  8. 如何掌握mysql的查询语句_如何分析mysql的查询语句
  9. 网页自动填表html,风越网页表单批量自动填写工具
  10. kettle作业定时如何在开源调度工具taskctl里实现
  11. 大数据职业理解_大数据的职业发展规划
  12. 智能家居系列之Home Assistant
  13. HTML使用无序列表制作一级菜单和二级下拉菜单
  14. 批处理文件 执行java_利用批处理文件运行java程序
  15. Jzoj3547 MEX
  16. 在线文件/文档预览/分页分片预览 之开源kkfileview(word转pdf,pdf截取,pdf转图片,Aspose jobConverter , OpenOffice ,libreoffice )
  17. 【R 数据科学】R语言进行数据科学整理最有用的包大全
  18. 【Visual C++】游戏开发五十 浅墨DirectX教程十八 雪花飞扬 实现唯美的粒子系统
  19. 汇川,H3U,plc程序模板和触摸屏程序模板,三个步进和三个伺服
  20. Calendar类常用api

热门文章

  1. “源”来是你-Vol.32 | 知名图数据平台 Neo4j 招聘中国社区经理
  2. python读写csv常用方法
  3. Centos7安装fish shell,介绍及使用
  4. ORACLE进阶(十)start with connect by 实现递归查询
  5. 微信小程序引入vant-weapp组件遇到的bug以及解决方法
  6. 【小程序从0到1】网络数据请求——request合法域名|GET|POST|跨域?Ajax?
  7. linux有数据恢复工具吗,Linux运维人员必备的数据恢复工具有哪些?
  8. 海尔小管家1号店嗨购盛典引爆 市场份额稳居红星美凯龙第一
  9. 祝贺一个逃离科研的博士
  10. 程序员圈 内的 鄙视链