luogu#P7949. [✗✓OI R1] 左方之地
[✗✓OI R1] 左方之地
Background
In the epilogue, it will be described in detail why the “Land of Saki” can become the leader of the “Six Handsome Guys of Toaru Majutsu no Index”.
If you are wondering why the title does not include “Vento of the Front”, then you may want to check div.2.
But before that, you need to solve a construction problem.
Problem Description
You are given a natural number and a natural number parameter . You need to construct a sequence of length such that every integer in appears exactly once, and for all , .
Here, denotes the number of bits in the binary representation of , and denotes the bitwise XOR operation.
If a solution exists, output 1 and print the sequence; otherwise, output 0.
Input Format
One line with two integers , with the same meaning as in the statement.
Output Format
Output one integer 0 or 1 on the first line, where 0 means that no such sequence exists, and 1 means that such a sequence exists.
If the first line is 1, output integers on the next line, representing the sequence you construct. If there are multiple valid sequences, output any one.
4 3
1
0 14 3 13 6 8 5 11 12 2 15 1 10 4 9 7
4 2
0
Hint
This problem uses Special Judge and subtask-based evaluation.
For of the testdata, it is guaranteed that .
| Subtask ID | Points | Dependencies | ||
|---|---|---|---|---|
| 0 | 5 | |||
| 1 | 25 | Subtask 0 | ||
| 2 | 10 | |||
| 3 | 15 | |||
| 4 | 45 | Subtask 0~3 | ||

Translated by ChatGPT 5