309107: CF1625D. Binary Spiders

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Binary Spiders

题意翻译

你收到了 $n$ 只蜘蛛,第 $i$ 只蜘蛛有 $a_i$ 条腿。科学家经过研究发现,这种蜘蛛的特殊之处在于,它们织出的网的大小和人类的位运算有关。具体地,一只 $x$ 条腿的蜘蛛和一只 $y$ 条腿的蜘蛛可以织出一个大小为 $x\operatorname{xor}y$ 的网,其中 $\operatorname{xor}$ 表示按位异或运算。 现在,你需要从中选出一些蜘蛛,使得其中任意一对蜘蛛都能够织出一个大小至少为 $k$ 的网。请求出是否能够选出蜘蛛满足要求,如果能,请求出最多能够选出的蜘蛛只数,并且给出**任意一组**满足要求的选出的蜘蛛的编号;如果不能,输出 `-1`。 数据范围: - $2\leqslant n\leqslant 3\times 10^5$,$0\leqslant k\leqslant 2^{30}-1$。 - $0\leqslant a_i\leqslant 2^{30}-1$。 Translated by Eason_AC 2022.1.19

题目描述

Binary Spiders are species of spiders that live on Mars. These spiders weave their webs to defend themselves from enemies. To weave a web, spiders join in pairs. If the first spider in pair has $ x $ legs, and the second spider has $ y $ legs, then they weave a web with durability $ x \oplus y $ . Here, $ \oplus $ means bitwise XOR. Binary Spiders live in large groups. You observe a group of $ n $ spiders, and the $ i $ -th spider has $ a_i $ legs. When the group is threatened, some of the spiders become defenders. Defenders are chosen in the following way. First, there must be at least two defenders. Second, any pair of defenders must be able to weave a web with durability at least $ k $ . Third, there must be as much defenders as possible. Scientists have researched the behaviour of Binary Spiders for a long time, and now they have a hypothesis that they can always choose the defenders in an optimal way, satisfying the conditions above. You need to verify this hypothesis on your group of spiders. So, you need to understand how many spiders must become defenders. You are not a Binary Spider, so you decided to use a computer to solve this problem.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ k $ ( $ 2 \le n \le 3\cdot10^5 $ , $ 0 \le k \le 2^{30} - 1 $ ), the amount of spiders in the group and the minimal allowed durability of a web. The second line contains $ n $ integers $ a_i $ ( $ 0 \le a_i \le 2^{30}-1 $ ) — the number of legs the $ i $ -th spider has.

输出格式


In the first line, print a single integer $ \ell $ ( $ 2 \le \ell \le n $ ), the maximum possible amount of defenders. In the second line, print $ \ell $ integers $ b_i $ , separated by a single space ( $ 1 \le b_i \le n $ ) — indices of spiders that will become defenders. If there exists more than one way to choose the defenders, print any of them. Unfortunately, it may appear that it's impossible to choose the defenders. In this case, print a single integer $ -1 $ .

输入输出样例

输入样例 #1

6 8
2 8 4 16 10 14

输出样例 #1

3
1 5 4

输入样例 #2

6 1024
1 2 3 1 4 0

输出样例 #2

-1

说明

Consider the examples above. In the first example, the group of spiders is illustrated on the picture below: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1625D/1010007e17d60a2fb95617e44d5646f679fa1136.png)We choose the two-legged, the ten-legged and the $ 16 $ -legged spiders. It's not hard to see that each pair may weave a web with enough durability, as $ 2 \oplus 10 = 8 \ge 8 $ , $ 2 \oplus 16 = 18 \ge 8 $ and $ 10 \oplus 16 = 26 \ge 8 $ . This is not the only way, as you can also choose, for example, the spiders with indices $ 3 $ , $ 4 $ , and $ 6 $ . In the second example, no pair of spiders can weave the web with durability $ 1024 $ or more, so the answer is $ -1 $ .

Input

题意翻译

你收到了 $n$ 只蜘蛛,第 $i$ 只蜘蛛有 $a_i$ 条腿。科学家经过研究发现,这种蜘蛛的特殊之处在于,它们织出的网的大小和人类的位运算有关。具体地,一只 $x$ 条腿的蜘蛛和一只 $y$ 条腿的蜘蛛可以织出一个大小为 $x\operatorname{xor}y$ 的网,其中 $\operatorname{xor}$ 表示按位异或运算。 现在,你需要从中选出一些蜘蛛,使得其中任意一对蜘蛛都能够织出一个大小至少为 $k$ 的网。请求出是否能够选出蜘蛛满足要求,如果能,请求出最多能够选出的蜘蛛只数,并且给出**任意一组**满足要求的选出的蜘蛛的编号;如果不能,输出 `-1`。 数据范围: - $2\leqslant n\leqslant 3\times 10^5$,$0\leqslant k\leqslant 2^{30}-1$。 - $0\leqslant a_i\leqslant 2^{30}-1$。 Translated by Eason_AC 2022.1.19

加入题单

上一题 下一题 算法标签: