CF1625D.Binary Spiders

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

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 xx legs, and the second spider has yy legs, then they weave a web with durability x⊕yx \oplus y. Here, ⊕\oplus means bitwise XOR.

Binary Spiders live in large groups. You observe a group of nn spiders, and the ii-th spider has aia_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 kk. 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.

二进制蜘蛛(Binary Spiders)是生活在火星上的一类蜘蛛,它们通过结网来抵御敌人。

织网时,蜘蛛两两配对。若配对中第一只蜘蛛有 xx 条腿,第二只蜘蛛有 yy 条腿,则它们织出的蛛网的耐久度为 x⊕yx \oplus y。此处 ⊕\oplus 表示按位异或(bitwise XOR)运算。

二进制蜘蛛以大型群体形式生活。你观察到一群共 nn 只蜘蛛,其中第 ii 只蜘蛛有 aia_i 条腿。

当群体受到威胁时,部分蜘蛛会成为守卫者(defenders)。守卫者的选取需满足如下规则:
第一,守卫者数量至少为 22;
第二,任意一对守卫者之间织成的蛛网耐久度均不小于 kk;
第三,在满足前两条的前提下,守卫者数量应尽可能多。

科学家们长期研究二进制蜘蛛的行为,并提出一个假设:对于任意蜘蛛群,总能以最优方式选出满足上述条件的守卫者。你需要在你所观察的这群蜘蛛上验证该假设。因此,你需要确定最多能有多少只蜘蛛成为守卫者。你并非二进制蜘蛛,故决定借助计算机解决此问题。

输入格式

The first line contains two integers nn and kk (2≤n≤3⋅1052 \le n \le 3\cdot10^5, 0≤k≤230−10 \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 nn integers aia_i (0≤ai≤230−10 \le a_i \le 2^{30}-1) — the number of legs the ii-th spider has.

第一行包含两个整数 nn 和 kk(2≤n≤3⋅1052 \le n \le 3\cdot10^5,0≤k≤230−10 \le k \le 2^{30} - 1),分别表示蜘蛛群中蜘蛛的数量以及蛛网的最小允许耐久度。

第二行包含 nn 个整数 aia_i(0≤ai≤230−10 \le a_i \le 2^{30}-1),表示第 ii 只蜘蛛的腿的数量。

输出格式

In the first line, print a single integer ℓ\ell (2≤ℓ≤n2 \le \ell \le n), the maximum possible amount of defenders.

In the second line, print ℓ\ell integers bib_i, separated by a single space (1≤bi≤n1 \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.

第一行,输出一个整数 ℓ\ell(2≤ℓ≤n2 \le \ell \le n),表示最多可选的守卫数量。

第二行,输出 ℓ\ell 个整数 bib_i,以单个空格分隔(1≤bi≤n1 \le b_i \le n)—— 表示将担任守卫的蜘蛛的编号。

若存在多种选择守卫的方式,输出任意一种即可。

不幸的是,有时可能无法选出满足条件的守卫。此时,仅输出一个整数 −1-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 1616-legged spiders. It's not hard to see that each pair may weave a web with enough durability, as 2⊕10=8≥82 \oplus 10 = 8 \ge 8, 2⊕16=18≥82 \oplus 16 = 18 \ge 8 and 10⊕16=26≥810 \oplus 16 = 26 \ge 8.

This is not the only way, as you can also choose, for example, the spiders with indices 33, 44, and 66.

In the second example, no pair of spiders can weave the web with durability 10241024 or more, so the answer is −1-1.

考虑上面的示例。

在第一个示例中,蜘蛛群如下图所示:

我们选择具有 22 条腿、1010 条腿和 1616 条腿的蜘蛛。不难验证,每一对蜘蛛均能编织出满足耐久度要求的蛛网,因为 2⊕10=8≥82 \oplus 10 = 8 \ge 8,2⊕16=18≥82 \oplus 16 = 18 \ge 8,且 10⊕16=26≥810 \oplus 16 = 26 \ge 8。

这并非唯一方案;例如,你也可以选择编号为 33、44 和 66 的蜘蛛。

在第二个示例中,不存在任意一对蜘蛛能编织出耐久度不低于 10241024 的蛛网,因此答案为 −1-1。

输入解题思路,AI测评打分。不知道怎么写?

首页