CF1835C.Twin Clusters

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Famous worldwide astrophysicist Mleil waGrasse Tysok recently read about the existence of twin galaxy clusters. Before he shares this knowledge with the broader audience in his podcast called S.tarT-ok, he wants to prove their presence on his own. Mleil is aware that the vastness of the universe is astounding (almost as astounding as his observation skills) and decides to try his luck and find some new pair of twin clusters.

To do so, he used his TLEscope to observe a part of the night sky that was not yet examined by humanity in which there are exactly 2k+12^{k + 1} galaxies in a row. ii-th of them consist of exactly 0≤gi<4k0 \le g_i \lt 4^k stars.

A galaxy cluster is any non-empty contiguous segment of galaxies. Moreover, its' trait is said to be equal to the bitwise XOR of all values gig_i within this range.

Two galaxy clusters are considered twins if and only if they have the same traits and their corresponding segments are disjoint.

Write a program that, for many scenarios, will read a description of a night sky part observed by Mleil and outputs a location of two intervals belonging to some twin clusters pair, or a single value −1-1 if no such pair exists.

世界著名天体物理学家米尔·瓦格拉斯·泰索克(Mleil waGrasse Tysok)最近了解到“孪生星系团”的存在。在他通过名为《S.tarT-ok》的播客向广大听众分享这一发现之前,他希望亲自证实其存在。米尔深知宇宙之浩瀚令人惊叹(其惊人程度几乎堪比他本人的观察能力),于是决定碰碰运气,自行寻找一对新的孪生星系团。

为此,他使用自己的 TLE望远镜观测了一片人类此前尚未探索过的夜空区域,该区域内恰好有 2k+12^{k + 1} 个星系排成一行。其中第 ii 个星系恰好包含 0≤gi<4k0 \le g_i \lt 4^k 颗恒星。

一个星系团指任意一个非空的连续星系段。此外,该星系团的特征值被定义为该段内所有 gig_i 值的按位异或(XOR)结果。

当且仅当两个星系团具有相同的特征值,且其所对应的区间互不相交(即无公共星系)时,它们才被称为孪生星系团。

请编写一个程序:对多个测试用例,读入米尔所观测的夜空区域描述,并输出某一对孪生星系团所对应两个区间的具体位置;若不存在这样的孪生星系团对,则仅输出单个整数 −1-1。

输入格式

The first line contains a single integer tt, denoting the number of test cases that the program has to handle. The following lines contain test case descriptions, each containing exactly two lines.

The first of them contains a single integer kk (0≤k≤170 \le k \le 17).

The second line contains 2k+12^{k + 1} integers g1,g2,…,g2k+1g_1, g_2, \ldots, g_{2^{k+1}} (0≤gi<4k0 \le g_i \lt 4^k).

We guarantee that the sum of values 2k+12^{k + 1} over all test cases does not exceed 2182^{18}.

第一行包含一个整数 tt,表示程序需要处理的测试用例数量。随后的行包含各测试用例的描述,每个测试用例恰好占两行。

第一行包含一个整数 kk(0≤k≤170 \le k \le 17)。

第二行包含 2k+12^{k + 1} 个整数 g1,g2,…,g2k+1g_1, g_2, \ldots, g_{2^{k+1}}(0≤gi<4k0 \le g_i \lt 4^k)。

我们保证所有测试用例中 2k+12^{k + 1} 的总和不超过 2182^{18}。

输出格式

Answers for all test cases should be present in separate lines. If there exist a pair of twin galaxies, then output four integers aa, bb, cc, and dd denoting their inclusive ranges [a,b][a, b] and [c,d][c, d] (the first interval does not need to start before the second one, but they have to be disjoint). If no pair of such galaxies exist, output a single value −1-1 instead.

所有测试用例的答案应分别输出在单独的行中。如果存在一对“孪生星系”,则输出四个整数 aa、bb、cc 和 dd,表示它们的闭区间 [a,b][a, b] 和 [c,d][c, d](第一个区间无需在第二个区间之前开始,但这两个区间必须互不相交)。若不存在这样的星系对,则输出单个值 −1-1。

输入输出样例

  • 输入#1

    4
    2
    4 15 0 7 11 8 3 2
    1
    0 1 2 3
    0
    0 0
    3
    15 63 57 39 61 25 42 61 50 41 27 41 56 23 17 27

    输出#1

    2 4 6 6
    2 2 3 4
    1 1 2 2
    1 1 4 10

说明/提示

In the first test case we pick intervals [2,4][2, 4] and [6,6][6, 6] as our twin clusters. The trait of the first interval equals 15⊕0⊕7=815 \oplus 0 \oplus 7 = 8, and the trait of the second interval equals 88, so these galaxy clusters are indeed twins.

在第一个测试用例中,我们选择区间 [2,4][2, 4] 和 [6,6][6, 6] 作为我们的孪生星系团。第一个区间的特征值为 15⊕0⊕7=815 \oplus 0 \oplus 7 = 8,第二个区间的特征值也为 88,因此这两个星系团确实是孪生的。

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

首页