#P8468. [Aya Round 1 C] 文文的构造游戏

    ID: 9569 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 显示难度普及− 上传者: 标签>数学洛谷原创Special JudgeO2优化构造洛谷月赛

[Aya Round 1 C] 文文的构造游戏

Background

Problem Number: 23\textit{23}

As everyone knows, Shameimaru Aya and Cirno are good friends. However, Aya is a powerful youkai and very smart, while Cirno is a fool. To improve Cirno’s IQ, Aya gave Cirno a simple problem.

Problem Description

For a sequence pp of length ll, define S(p)S(p) as the bitwise XOR sum of all elements, where ⊕\oplus denotes the bitwise XOR operation.

Given integers s,ms, m, determine whether it is possible to construct a sequence aa of length nn (you may choose nn) such that:

  • 1≤n≤m1 \le n \le m.
  • 1≤ai≤s1 \le a_i \le s.
  • S(a)=0S(a) = 0.
  • a1+a2+⋯+an=sa_1 + a_2 + \cdots + a_n = s.

Construct any valid solution, or report that no solution exists.

Input Format

This problem contains multiple test cases.

  • The first line contains an integer TT, the number of test cases.
  • The next TT lines each contain two integers s,ms, m, representing one query.

Output Format

  • Output a total of TT lines.
  • For each test case:
    • If there is a solution, first output an integer nn, then output nn integers representing aa.
    • If there is no solution, output a single integer −1-1 on one line.
2
14 9
3 3
3 3 5 6
-1

Hint

Sample Explanation

  • For test case 11, it is easy to see that 3⊕5⊕6=03 \oplus 5 \oplus 6 = 0 and 3+5+6=143 + 5 + 6 = 14, which satisfies the requirements.
  • For test case 22, the sequences {3}\{3\}, {1,2}\{1,2\}, and {1,1,1}\{1,1,1\} all do not satisfy the requirements, so there is no solution.

Constraints and Notes

For 100%100\% of the testdata, 1≤s≤10181 \le s \le 10^{18}, 1≤m1 \le m, and 1≤∑m≤1061 \le \sum m \le 10^6.

Friendly reminder: you may need to use faster I/O.

Translated by ChatGPT 5