#P9033. 「KDOI-04」XOR Sum

    ID: 9974 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>洛谷原创Special JudgeO2优化构造洛谷月赛

「KDOI-04」XOR Sum

Background

Kevin solved this problem at a glance.

Problem Description

Given a positive integer nn, construct a sequence a1,a2,,ana_1,a_2,\dots,a_n of length nn consisting of non-negative integers, such that:

  • For all 1in1\le i\le n, we have 0aim0\le a_i\le m.
  • a1a2an=ka_1\oplus a_2\oplus\dots\oplus a_n=k, where \oplus denotes the bitwise XOR operation.

Or determine that no such sequence exists.

Input Format

This problem contains multiple test cases.

The first line of the input contains a positive integer TT, denoting the number of test cases.

For each test case, the input contains one line with three non-negative integers n,k,mn,k,m.

Output Format

For each test case, output one line with 1-1 to indicate that no such sequence exists.

Otherwise, output nn non-negative integers separated by spaces, representing the sequence you construct. If there are multiple valid answers, you only need to output any one of them.

5
1 2 2
2 3 10
2 11 8
20 200000 99999
11 191 9810
2 
4 7 
8 3 
-1
191 191 191 191 191 191 191 191 191 191 191 

Hint

[Sample Explanation]

For the 11st test case, there is one and only one sequence that satisfies the conditions.

For the 22nd test case, since 47=34\oplus 7=3 and 4,7104,7\le10, this is a valid answer. Similarly, the sequence (2,1)(2,1) is also a valid answer.

For the 44th test case, it can be proven that there is no sequence that meets the requirements.

[Constraints]

Let n\sum n be the sum of all nn values within a single test point.

For all testdata, it is guaranteed that 1T1 0001\le T\le 1~000, 1n21051\le n\le 2\cdot10^5, 0m,k1080\le m,k\le 10^8, and n2105\sum n\le 2\cdot10^5.

[Subtasks]

This problem uses bundled test cases.

  • Subtask 1 (18 pts): kmk\le m.
  • Subtask 2 (82 pts): No additional constraints.

Translated by ChatGPT 5