CF1604B.XOR Specia-LIS-t
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
YouKn0wWho has an integer sequence a1,a2,…an . Now he will split the sequence a into one or more consecutive subarrays so that each element of a belongs to exactly one subarray. Let k be the number of resulting subarrays, and h1,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] into [2,5,3,1,4] , [3,2,2,5] , [1] , then h=[3,2,1] .
YouKn0wWho wonders if it is possible to split the sequence a in such a way that the bitwise XOR of h1,h2,…,hk is equal to 0 . You have to tell whether it is possible.
The longest increasing subsequence (LIS) of a sequence b1,b2,…,bm is the longest sequence of valid indices i1,i2,…,ik such that i1<i2<…<ik and bi1<bi2<…<bik . For example, the LIS of [2,5,3,3,5] is [2,3,5] , which has length 3 .
An array c is a subarray of an array b if c can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.
输入格式
The first line contains a single integer t ( 1≤t≤10000 ) — the number of test cases.
The first line of each test case contains a single integer n ( 2≤n≤105 ).
The second line of each test case contains n integers a1,a2,…,an ( 1≤ai≤109 ).
It is guaranteed that the sum of n over all test cases doesn't exceed 3⋅105 .
输出格式
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).
输入输出样例
输入#1
4 7 1 3 4 2 2 1 5 3 1 3 4 5 1 3 2 4 2 4 4 3 2 1
输出#1
YES NO YES YES
说明/提示
In the first test case, YouKn0wWho can split the sequence in the following way: [1,3,4] , [2,2] , [1,5] . This way, the LIS lengths are h=[3,1,2] , and the bitwise XOR of the LIS lengths is 3⊕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.