CF2057C.Trip to the Olympiad

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

In the upcoming year, there will be many team olympiads, so the teachers of "T-generation" need to assemble a team of three pupils to participate in them. Any three pupils will show a worthy result in any team olympiad. But winning the olympiad is only half the battle; first, you need to get there...

Each pupil has an independence level, expressed as an integer. In "T-generation", there is exactly one student with each independence levels from ll to rr, inclusive. For a team of three pupils with independence levels aa, bb, and cc, the value of their team independence is equal to (a⊕b)+(b⊕c)+(a⊕c)(a \oplus b) + (b \oplus c) + (a \oplus c), where ⊕\oplus denotes the bitwise XOR operation.

Your task is to choose any trio of students with the maximum possible team independence.

在即将到来的一年中,将举行多场团体奥林匹克竞赛,因此“T-generation”学校的老师们需要组建一支由三名学生组成的队伍来参加这些比赛。任意三名学生组成的队伍在任何团体奥林匹克竞赛中都能取得优异的成绩。但赢得竞赛仅是成功的一半;首先,你得先抵达赛场……

每名学生都有一个独立性水平,用一个整数表示。“T-generation”学校中,恰好有且仅有一名学生的独立性水平为 ll 到 rr(含端点)之间的每一个整数值。对于独立性水平分别为 aa、bb 和 cc 的三名学生组成的队伍,其团队独立性值定义为 (a⊕b)+(b⊕c)+(a⊕c)(a \oplus b) + (b \oplus c) + (a \oplus c),其中 ⊕\oplus 表示按位异或运算。

你的任务是:从所有可能的三人组合中,任选一组使得其团队独立性值达到最大可能值。

输入格式

Each test contains multiple test cases. The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case set contains two integers ll and rr (0≤l,r<2300 \le l, r \lt 2^{30}, r−l>1r - l \gt 1) — the minimum and maximum independence levels of the students.

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

每个测试用例的第一行包含两个整数 ll 和 rr(0≤l,r<2300 \le l, r \lt 2^{30},且 r−l>1r - l \gt 1)—— 学生的最低和最高独立性水平。

输出格式

For each test case set, output three pairwise distinct integers a,ba, b, and cc, such that l≤a,b,c≤rl \le a, b, c \le r and the value of the expression (a⊕b)+(b⊕c)+(a⊕c)(a \oplus b) + (b \oplus c) + (a \oplus c) is maximized. If there are multiple triples with the maximum value, any of them can be output.

对于每组测试用例,输出三个互不相同的整数 aa、bb 和 cc,满足 l≤a,b,c≤rl \le a, b, c \le r,并使得表达式 (a⊕b)+(b⊕c)+(a⊕c)(a \oplus b) + (b \oplus c) + (a \oplus c) 的值最大化。若存在多个达到最大值的三元组,输出任意一个即可。

输入输出样例

  • 输入#1

    8
    0 2
    0 8
    1 3
    6 22
    128 137
    69 98
    115 127
    0 1073741823

    输出#1

    1 2 0
    8 7 1
    2 1 3
    7 16 11
    134 132 137
    98 85 76
    123 121 118
    965321865 375544086 12551794

说明/提示

In the first test case, the only suitable triplet of numbers (a,b,ca, b, c) (up to permutation) is (0,1,20, 1, 2).

In the second test case, one of the suitable triplets is (8,7,18, 7, 1), where (8⊕7)+(7⊕1)+(8⊕1)=15+6+9=30(8 \oplus 7) + (7 \oplus 1) + (8 \oplus 1) = 15 + 6 + 9 = 30. It can be shown that 3030 is the maximum possible value of (a⊕b)+(b⊕c)+(a⊕c)(a \oplus b) + (b \oplus c) + (a \oplus c) for 0≤a,b,c≤80 \le a, b, c \le 8.

在第一个测试用例中,唯一满足条件的三元组数字(不考虑排列顺序)为 (0,1,2)(0, 1, 2)。

在第二个测试用例中,一个满足条件的三元组是 (8,7,1)(8, 7, 1),其中 (8⊕7)+(7⊕1)+(8⊕1)=15+6+9=30(8 \oplus 7) + (7 \oplus 1) + (8 \oplus 1) = 15 + 6 + 9 = 30。可以证明:当 0≤a,b,c≤80 \le a, b, c \le 8 时,(a⊕b)+(b⊕c)+(a⊕c)(a \oplus b) + (b \oplus c) + (a \oplus c) 的最大可能值为 3030。

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

首页