CF1720D1.Xor-Subsequence (easy version)

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

It is the easy version of the problem. The only difference is that in this version ai200a_i \le 200 .

You are given an array of nn integers a0,a1,a2,an1a_0, a_1, a_2, \ldots a_{n - 1} . Bryap wants to find the longest beautiful subsequence in the array.

An array b=[b0,b1,,bm1]b = [b_0, b_1, \ldots, b_{m-1}] , where 0b0<b1<<bm1<n0 \le b_0 < b_1 < \ldots < b_{m - 1} < n , is a subsequence of length mm of the array aa .

Subsequence b=[b0,b1,,bm1]b = [b_0, b_1, \ldots, b_{m-1}] of length mm is called beautiful, if the following condition holds:

  • For any pp ( 0p<m10 \le p < m - 1 ) holds: abpbp+1<abp+1bpa_{b_p} \oplus b_{p+1} < a_{b_{p+1}} \oplus b_p .

Here aba \oplus b denotes the bitwise XOR of aa and bb . For example, 24=62 \oplus 4 = 6 and 31=23 \oplus 1=2 .

Bryap is a simple person so he only wants to know the length of the longest such subsequence. Help Bryap and find the answer to his question.

输入格式

The first line contains a single integer tt ( 1t1051 \leq t \leq 10^5 ) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn ( 2n31052 \leq n \leq 3 \cdot 10^5 ) — the length of the array.

The second line of each test case contains nn integers a0,a1,...,an1a_0,a_1,...,a_{n-1} ( 0ai2000 \leq a_i \leq 200 ) — the elements of the array.

It is guaranteed that the sum of nn over all test cases does not exceed 31053 \cdot 10^5 .

输出格式

For each test case print a single integer — the length of the longest beautiful subsequence.

输入输出样例

  • 输入#1

    3
    2
    1 2
    5
    5 2 4 3 1
    10
    3 8 8 2 9 1 6 2 8 3

    输出#1

    2
    3
    6

说明/提示

In the first test case, we can pick the whole array as a beautiful subsequence because 11<201 \oplus 1 < 2 \oplus 0 .

In the second test case, we can pick elements with indexes 11 , 22 and 44 (in 00 -indexation). For this elements holds: 22<412 \oplus 2 < 4 \oplus 1 and 44<124 \oplus 4 < 1 \oplus 2 .

首页