AT_arc221_e.Two Increasing Sequences
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a positive integer N, a positive integer X, and a permutation P=(P1,P2,…,PN) of (1,2,…,N). Only X is given in binary, while N and the elements of P are given in decimal.
Determine whether there exist sequences of non-negative integers A=(A1,A2,…,AN) and B=(B1,B2,…,BN) satisfying all of the following conditions.
- Both A and B are strictly increasing sequences.
- APi=Bi⊕X holds for i=1,2,…,N.
Here, the binary operator ⊕ denotes the bitwise XOR of non-negative integers.
You are given T test cases; solve each of them.
给你一个正整数 N、一个正整数 X,以及 (1,2,…,N) 的一个排列 P=(P1,P2,…,PN)。其中仅 X 以二进制形式给出,而 N 和排列 P 的各元素均以十进制形式给出。
请判断是否存在两个非负整数序列 A=(A1,A2,…,AN) 和 B=(B1,B2,…,BN),同时满足以下所有条件:
- 序列 A 和 B 均为严格递增序列;
- 对于 i=1,2,…,N,均有 APi=Bi⊕X 成立。
此处,二元运算符 ⊕ 表示非负整数的按位异或(bitwise XOR)。
你将得到 T 组测试用例,请对每组分别求解。
输入格式
The input is given from Standard Input in the following format:
T
case1
case2
⋮
caseT
Each test case is given in the following format:
N
X
P1 P2 … PN
输入从标准输入中按以下格式给出:
T
case1
case2
⋮
caseT
每个测试用例按以下格式给出:
N
X
P1 P2 … PN
输出格式
Output the answers for the test cases in order, separated by newlines.
For each test case, output Yes if there exist A and B satisfying all the conditions, and No otherwise.
按顺序输出各测试用例的答案,答案之间用换行符分隔。
对每个测试用例,若存在满足所有条件的 A 和 B,则输出 Yes;否则输出 No。
输入输出样例
输入#1
3 4 101 3 4 2 1 4 100 4 3 2 1 8 1101011 3 5 4 1 2 6 8 7
输出#1
Yes No Yes
说明/提示
Sample 1 Explanation:
For the first test case, for example, A=(2,3,5,7) and B=(0,2,6,7) satisfy the conditions.
Constraints
- 1≤T≤105
- 2≤N≤2×105
- 1≤X<2106
- P is a permutation of (1,2,…,N).
- The sum of N over all test cases is at most 2×105.
- The sum of the number of digits of X in binary over all test cases is at most 106.
- T,N,Pi are given in decimal.
- X is given in binary without leading zeros.
- All input values are integers.
样例 1 解释:
对于第一个测试用例,例如,A=(2,3,5,7) 和 B=(0,2,6,7) 满足条件。
约束条件
- 1≤T≤105
- 2≤N≤2×105
- 1≤X<2106
- P 是 (1,2,…,N) 的一个排列。
- 所有测试用例的 N 之和不超过 2×105。
- 所有测试用例中 X 的二进制表示的位数之和不超过 106。
- T、N、Pi 均以十进制给出。
- X 以二进制给出,且不含前导零。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?