CF1625D.Binary Spiders
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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⊕y . Here, ⊕ means bitwise XOR.
Binary Spiders live in large groups. You observe a group of n spiders, and the i -th spider has ai 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≤n≤3⋅105 , 0≤k≤230−1 ), the amount of spiders in the group and the minimal allowed durability of a web.
The second line contains n integers ai ( 0≤ai≤230−1 ) — the number of legs the i -th spider has.
输出格式
In the first line, print a single integer ℓ ( 2≤ℓ≤n ), the maximum possible amount of defenders.
In the second line, print ℓ integers bi , separated by a single space ( 1≤bi≤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:
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⊕10=8≥8 , 2⊕16=18≥8 and 10⊕16=26≥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 .