#P15651. [省选联考 2026] 夜空
[省选联考 2026] 夜空
Background
Legend has it that a long time ago, the little monster Nexus committed many evil deeds, so the great mage sealed it into the night sky. To complete the seal, the great mage cast spells to rearrange the stars, making the night sky show a specific constellation.
It is said that this seal has lasted to this day, and no one knows what it fully looked like in the past.
Problem Description
When reading ancient books, Little H discovered that the stars in the night sky can be abstracted as a sequence of non-negative integers. The star sequence in ancient times was , and the sequence observed today is .
The ancient book also records two kinds of spells used by the great mage when rearranging the stars. Specifically, for a current star sequence of length at least , the great mage may cast one of the following two spells:
- Delete the leftmost two elements of the sequence, and insert their XOR sum at the rightmost end.
- Delete the rightmost two elements of the sequence, and insert their XOR sum at the leftmost end.
It can be seen that each time a spell is cast, the length of the star sequence decreases by exactly . Little H suspects that perhaps the great mage used only these two spells back then, casting exactly times, turning the original sequence into the current sequence . You need to help him determine whether this is possible; if it is possible, you also need to find a specific sequence of spells.
Input Format
This problem contains multiple test cases.
The first line of the input contains two non-negative integers , representing the subtask ID and the number of test cases, respectively. indicates that this subtask is the sample.
Then the test cases follow. For each test case:
- The first line contains two positive integers .
- The second line contains non-negative integers .
- The third line contains non-negative integers .
Output Format
For each test case:
- Output a string
YesorNoin the first line, indicating whether it is possible that the great mage transformed sequence into sequence using only these two spells. - If possible, output positive integers from in the second line, indicating the type of spell cast each time.
You can get partial credit by answering the first part correctly. For detailed scoring rules, see 【Scoring】.
0 5
2 2
1 2
1 2
3 2
3 4 2
6 3
5 3
2 3 4 5 6
6 1 1
6 1
1 2 3 4 5 6
0
7 2
3 3 5 6 1 2 8
11 3
Yes
Yes
2
Yes
1 1
No
Yes
2 1 2 1 1
Hint
【Sample 1 Explanation】
This sample contains five test cases in total.
For the first test case, sequences and are the same, so no spell needs to be cast.
For the second test case, after casting one spell of type , the rightmost and of sequence are deleted, and is inserted at the leftmost end, obtaining sequence .
For the third test case:
- After casting one spell of type , the leftmost and of sequence are deleted, and is inserted at the rightmost end, obtaining the sequence .
- After casting another spell of type , the leftmost and are deleted, and is inserted at the rightmost end, obtaining sequence .
For the fourth test case, it can be proven that using only these two spells cannot transform sequence into sequence .
【Sample 2】
See night/night2.in and night/night2.ans under the contestant directory.
This sample satisfies the constraints of subtasks .
【Sample 3】
See night/night3.in and night/night3.ans under the contestant directory.
This sample satisfies the constraints of subtask .
【Sample 4】
See night/night4.in and night/night4.ans under the contestant directory.
This sample satisfies the constraints of subtasks .
【Sample 5】
See night/night5.in and night/night5.ans under the contestant directory.
This sample satisfies the constraints of subtasks .
【Constraints】
For all testdata:
- ;
- ;
- For all , ;
- For all , .
::cute-table{tuack}
| Subtask ID | Special Property | |||
|---|---|---|---|---|
| None | ||||
| ^ | ||||
| ^ | ^ | |||
| ^ | A | |||
| B | ||||
| ^ | ||||
| C | ||||
| ^ | ||||
| D | ||||
| ^ | ||||
| None | ||||
| ^ | ||||
A sequence is defined to be bizarre if and only if , and , and for all , .
The cyclic shift of a sequence is defined as follows: for a positive integer (), the sequence is a cyclic shift of .
- Special Property A: .
- Special Property B: sequences are both bizarre.
- Special Property C: each of sequences and has a cyclic shift that is bizarre.
- Special Property D: .
【Scoring】
This problem contains two parts. For each subtask:
- Part 1: For each test case in this subtask, if you correctly determine feasibility, you will get of the score for this subtask.
- Part 2: Based on that, if for each test case with answer
Yesyou can also correctly output a valid sequence of spells, you will get the remaining of the score for this subtask.
Note: For test cases with answer Yes, regardless of whether the contestant attempts to output a correct sequence of spells, you must output positive integers from in the second line to satisfy the output format.
【Hint】
A checker.cpp is provided in the problem directory to check the validity of the spell sequence. Note: the provided checker.cpp only checks the correctness of the spell sequence for test cases whose answer is Yes, and does not check whether your feasibility judgment is correct.
Contestants can compile it into an executable in the problem directory using the following command:
g++ checker.cpp -o checker -std=gnu++14 -O2 -static
After compilation, contestants can test in the problem directory using the following command:
./checker <input_file> <output_file>
Here, <input_file> and <output_file> are the paths of the input file and the output file, respectively.
Note: The input file provided by the contestant must satisfy the input format and constraints given in the problem statement, and the output file must satisfy the given output format. Otherwise, the checking result is not guaranteed to be correct, and unexpected errors may occur.
Translated by ChatGPT 5