#P9591. 「PFLOI R1」PFL 变换

    ID: 10848 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>洛谷原创Special JudgeO2优化模拟退火构造Ad-hoc分类讨论

「PFLOI R1」PFL 变换

Background

Five top experts have gathered here, and sparks of ideas collide fiercely. Soon, PFLOI Round 1 is ready.

It begins...

Problem Description

A new journey has begun: Zhili has set out to look for bananas. There are a total of nn bananas on the road, numbered from 11 to nn.

Seeing such delicious food, Zhili is very excited. However, Zhili does not want to eat too much or too little, so it will eat exactly mm bananas.

Zhili is very picky. It will only be satisfied if the XOR sum of the indices of the mm bananas it eats is exactly 2log2n+112^{\lfloor\log_2 n\rfloor+1}-1. Please help find which bananas it should eat to make it satisfied.

If Zhili's requirement cannot be satisfied no matter what, please output -1.


Formal statement:

Please choose mm numbers from 11 to nn such that their XOR sum is exactly 2log2n+112^{\lfloor\log_2 n\rfloor+1}-1. If there is no solution, output -1.

Input Format

This problem has multiple test cases.

The first line contains an integer TT, meaning there are TT test cases in total.

For each test case, each line contains two integers nn and mm, with meanings as described in the statement.

Output Format

For each test case, if there is a solution, output one line with mm integers, representing the mm numbers you choose. If there is no solution, output -1.

This problem uses Special Judge. If there are multiple possible solutions, you may output any one of them.

7
5 2
6 6
7 6
8 3
9 3
10 1
7 4
3 4
1 6 2 4 3 5 
1 2 3 4 5 6
8 6 1
8 1 6
-1
3 5 6 7

Hint

This problem does not use bundled tests.

Test Point ID Special Property Score
1,21,2 n15n\le15 2×4=82\times4=8
3113\sim11 n128n\le128 9×3=279\times3=27
122412\sim24 n105\sum n\le10^5 13×3=3913\times3=39
252925\sim29 No special restrictions 5×4=205\times4=20
3030 1×6=61\times6=6

Constraints: For all testdata, 1mn1061\le m\le n\le10^6, 1n,T1061\le\sum n,T\le10^6.

Translated by ChatGPT 5