CF1851F.Lisa and the Martians

普及+/提高

通过率:0%

时间限制:3.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Lisa was kidnapped by martians! It okay, because she has watched a lot of TV shows about aliens, so she knows what awaits her. Let's call integer martian if it is a non-negative integer and strictly less than 2k2^k, for example, when k=12k = 12, the numbers 5151, 19601960, 00 are martian, and the numbers π\pi, −1-1, 218\frac{21}{8}, 40964096 are not.

The aliens will give Lisa nn martian numbers a1,a2,…,ana_1, a_2, \ldots, a_n. Then they will ask her to name any martian number xx. After that, Lisa will select a pair of numbers ai,aja_i, a_j (i≠ji \neq j) in the given sequence and count (ai⊕x)&(aj⊕x)(a_i \oplus x) \& (a_j \oplus x). The operation ⊕\oplus means Bitwise exclusive OR, the operation &\& means Bitwise And. For example, (5⊕17)&(23⊕17)=(001012⊕100012)&(101112⊕100012)=101002&001102=001002=4(5 \oplus 17) \& (23 \oplus 17) = (00101_2 \oplus 10001_2) \& (10111_2 \oplus 10001_2) = 10100_2 \& 00110_2 = 00100_2 = 4.

Lisa is sure that the higher the calculated value, the higher her chances of returning home. Help the girl choose such i,j,xi, j, x that maximize the calculated value.

莉萨被火星人绑架了!不过没关系,因为她看过很多关于外星人的电视剧,所以她知道接下来会发生什么。我们称一个整数为“火星数”,当且仅当它是一个非负整数,且严格小于 2k2^k。例如,当 k=12k = 12 时,数字 5151、19601960、00 是火星数,而 π\pi、−1-1、218\frac{21}{8}、40964096 不是火星数。

外星人将给莉萨 nn 个火星数 a1,a2,…,ana_1, a_2, \ldots, a_n。然后他们会让她任选一个火星数 xx。接着,莉萨需从给定序列中选出一对数 ai,aja_i, a_j(其中 i≠ji \neq j),并计算 (ai⊕x)&(aj⊕x)(a_i \oplus x) \& (a_j \oplus x)。运算符 ⊕\oplus 表示按位异或,运算符 &\& 表示按位与。例如,(5⊕17)&(23⊕17)=(001012⊕100012)&(101112⊕100012)=101002&001102=001002=4(5 \oplus 17) \& (23 \oplus 17) = (00101_2 \oplus 10001_2) \& (10111_2 \oplus 10001_2) = 10100_2 \& 00110_2 = 00100_2 = 4。

莉萨确信,计算出的值越大,她回家的机会就越高。请帮助这位女孩选择满足条件的 i,j,xi, j, x,使得该计算值最大化。

输入格式

The first line contains an integer tt (1≤t≤1041 \le t \le 10^4) — number of testcases.

Each testcase is described by two lines.

The first line contains integers n,kn, k (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5, 1≤k≤301 \le k \le 30) — the length of the sequence of martian numbers and the value of kk.

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (0≤ai<2k0 \le a_i \lt 2^k) — a sequence of martian numbers.

It is guaranteed that the sum of nn over all testcases does not exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 测试用例的数量。

每个测试用例由两行描述。

第一行包含两个整数 n,kn, k(2≤n≤2⋅1052 \le n \le 2 \cdot 10^5,1≤k≤301 \le k \le 30)—— 火星数字序列的长度以及 kk 的值。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(0≤ai<2k0 \le a_i \lt 2^k)—— 一个火星数字序列。

保证所有测试用例的 nn 之和不超过 2⋅1052 \cdot 10^5。

输出格式

For each testcase, print three integers i,j,xi, j, x (1≤i,j≤n1 \le i, j \le n, i≠ji \neq j, 0≤x<2k0 \le x \lt 2^k). The value of (ai⊕x)&(aj⊕x)(a_i \oplus x) \& (a_j \oplus x) should be the maximum possible.

If there are several solutions, you can print any one.

对于每个测试用例,输出三个整数 i,j,xi, j, x(满足 1≤i,j≤n1 \le i, j \le n,i≠ji \neq j,0≤x<2k0 \le x \lt 2^k)。使得 (ai⊕x)&(aj⊕x)(a_i \oplus x) \& (a_j \oplus x) 的值达到最大可能。

若存在多个解,输出任意一个即可。

输入输出样例

  • 输入#1

    10
    5 4
    3 9 1 4 13
    3 1
    1 0 1
    6 12
    144 1580 1024 100 9 13
    4 3
    7 3 0 4
    3 2
    0 0 1
    2 4
    12 2
    9 4
    6 14 9 4 4 4 5 10 2
    2 1
    1 0
    2 4
    11 4
    9 4
    2 11 10 1 6 9 11 0 5

    输出#1

    1 3 14
    1 3 0
    5 6 4082
    2 3 7
    1 2 3
    1 2 15
    4 5 11
    1 2 0
    1 2 0
    2 7 4

说明/提示

First testcase: (3⊕14)&(1⊕14)=(00112⊕11102)&(00012⊕11102)=11012=11012&11112=11012=13(3 \oplus 14) \& (1 \oplus 14) = (0011_2 \oplus 1110_2) \& (0001_2 \oplus 1110_2) = 1101_2 = 1101_2 \& 1111_2 = 1101_2 = 13.

Second testcase: (1⊕0)&(1⊕0)=1(1 \oplus 0) \& (1 \oplus 0) = 1.

Third testcase: (9⊕4082)&(13⊕4082)=4091(9 \oplus 4082) \& (13 \oplus 4082) = 4091.

Fourth testcase: (3⊕7)&(0⊕7)=4(3 \oplus 7) \& (0 \oplus 7) = 4.

第一个测试用例:(3⊕14)&(1⊕14)=(00112⊕11102)&(00012⊕11102)=11012=11012&11112=11012=13(3 \oplus 14) \& (1 \oplus 14) = (0011_2 \oplus 1110_2) \& (0001_2 \oplus 1110_2) = 1101_2 = 1101_2 \& 1111_2 = 1101_2 = 13。

第二个测试用例:(1⊕0)&(1⊕0)=1(1 \oplus 0) \& (1 \oplus 0) = 1。

第三个测试用例:(9⊕4082)&(13⊕4082)=4091(9 \oplus 4082) \& (13 \oplus 4082) = 4091。

第四个测试用例:(3⊕7)&(0⊕7)=4(3 \oplus 7) \& (0 \oplus 7) = 4。

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

首页