欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1720D1.Xor-Subsequence (easy version)
Xor-Subsequence (easy version)
CF1720D1 · Xor-Subsequence (easy version)
- 难度:1800
- 标签:bitmasks、brute force、dp、strings、trees、two pointers
- 链接:https://codeforces.com/problemset/problem/1720/D1
- 时间限制:2 seconds 内存限制:512 megabytes
- 出现位置:Day22-阶段模拟4-S T1-T3综合卷
英文原题面
Statement
It is the easy version of the problem. The only difference is that in this version . You are given an array of integers . Bryap wants to find the longest beautiful subsequence in the array. An array , where $0 \le b_0 \lt b_1 \lt \ldots \lt b_{m - 1} \lt n$, is a subsequence of length of the array . Subsequence of length is called beautiful, if the following condition holds:
- For any () holds: $a_{b_p} \oplus b_{p+1} \lt a_{b_{p+1}} \oplus b_p$.
Here denotes the bitwise XOR of and . For example, and . 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.
Input
The first line contains a single integer () — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer () — the length of the array. The second line of each test case contains integers () — the elements of the array. It is guaranteed that the sum of over all test cases does not exceed .
Output
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
输出:
2
3
6
样例解释(英文原文)
In the first test case, we can pick the whole array as a beautiful subsequence because . In the second test case, we can pick elements with indexes , and (in -indexation). For this elements holds: and .
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |