#P8942. Digital Fortress
Digital Fortress
Background
Brinkhoff shouted loudly, “Of course it’s a password! If it’s not a password, what else could it be? Why else would Ugha give away this ring? Who would engrave a long string of messy letters on a ring?”
Fontaine glared at Brinkhoff angrily, making him quiet down.
“Uh… guys?” Beck cut in, as if he really did not want to get involved. “You keep saying these are messy letters. I think I should tell you… the letters engraved on this ring are not messy at all. If you look closely, you’ll see that actually, these letters… well… this is Latin.”
Everyone at the command console looked at the ring. It read:
Quis custodiet ipsos custiodies.
Who will watch the watchers…
Problem Description
A deadly mutated string has passed through the X-11 filter and gone deep into the NSA database. Susan and Beck must crack the password immediately to shut down the worm virus.
In the worm’s files, they found some properties of the password:
- It has numbers, each in , and the sequence is non-decreasing.
- If you compute the prefix XOR sums, the prefix XOR sums are also non-decreasing.
- If you compute the suffix XOR sums, the suffix XOR sums are still non-decreasing.
Besides this, they also found the values of . Now they need to construct a password sequence that satisfies all properties.
[Formal statement]
Determine whether there exists a non-decreasing positive integer sequence of length , with all elements in the range , such that:
- $\forall1<i\le n,a_1\ \text{xor}\ a_2\ \text{xor}\ \cdots\ \text{xor}\ a_{i-1}\le a_1\ \text{xor}\ a_2\ \text{xor}\ \cdots\ \text{xor}\ a_{i}$
- $\forall1\le i<n,a_n\ \text{xor}\ a_{n-1}\ \text{xor}\ \cdots\ \text{xor}\ a_{i+1}\le a_n\ \text{xor}\ a_{n-1}\ \text{xor}\ \cdots\ \text{xor}\ a_{i}$
If it exists, output one valid solution. There are multiple test cases.
Input Format
The first line contains a positive integer , the number of test cases.
For each test case, input two positive integers .
Output Format
For each test case, if there is no password that meets the requirements, output No. Otherwise, output Yes, and on the next line output one valid construction.
2
4 20
1919 114514
Yes
1 6 8 16
No
Hint
[Sample explanation]
For the first test case, the prefix XOR sums are , and the suffix XOR sums are . Both are increasing sequences, so the requirements are satisfied.
For the second test case, there is no valid construction.
[Constraints]
This problem uses bundled testdata.
| Score | |||
|---|---|---|---|
For of the testdata, , , .
Translated by ChatGPT 5