308957: CF1604B. XOR Specia-LIS-t
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
XOR Specia-LIS-t
题意翻译
### 题目描述 给定一个长度为 $n$ 的序列 $a_1,a_2,\dots,a_n$,能否将这个序列分成几段,使每一段的最大上升子序列的长度的异或和等于 $0$。 ### 输入格式 第一行输入一个正整数 $t$ 表示数据组数。 每组数据输入两行,第一行为一个正整数 $n$ 表示一个序列,第二行 $n$ 个正整数表示序列 $a$。 ### 输出格式 每组数据输出一行,如果能,输出 `YES`,否则输出 `NO`。 ### 数据范围 $1\le t\le10^4,2\le n\le10^5,2\le \sum n\le3\times10^5,1\le a_i\le10^9$。题目描述
YouKn0wWho has an integer sequence $ a_1, a_2, \ldots a_n $ . 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 $ h_1, h_2, \ldots, h_k $ 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](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of $ h_1, h_2, \ldots, h_k $ is equal to $ 0 $ . You have to tell whether it is possible. The longest increasing subsequence (LIS) of a sequence $ b_1, b_2, \ldots, b_m $ is the longest sequence of valid indices $ i_1, i_2, \ldots, i_k $ such that $ i_1 \lt i_2 \lt \ldots \lt i_k $ and $ b_{i_1} \lt b_{i_2} \lt \ldots \lt b_{i_k} $ . 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 \le t \le 10\,000 $ ) — the number of test cases. The first line of each test case contains a single integer $ n $ ( $ 2 \le n \le 10^5 $ ). The second line of each test case contains $ n $ integers $ a_1, a_2, \ldots, a_n $ ( $ 1 \le a_i \le 10^9 $ ). It is guaranteed that the sum of $ n $ over all test cases doesn't exceed $ 3 \cdot 10^5 $ .
输出格式
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