2057C.md (2275B)
1 Source: https://codeforces.com/problemset/problem/2057/C 2 3 C. Trip to the Olympiad 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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... 22 23 Each pupil has an independence level, expressed as an integer. In "T-generation", there is exactly one student with each independence levels from $l$ to $r$, inclusive. For a team of three pupils with independence levels $a$, $b$, and $c$, the value of their team independence is equal to $(a \oplus b) + (b \oplus c) + (a \oplus c)$, where $\oplus$ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR). 24 25 Your task is to choose any trio of students with the maximum possible team independence. 26 27 Input 28 29 Each test contains multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases. The description of the test cases follows. 30 31 The first line of each test case set contains two integers $l$ and $r$ ($0 \le l, r \lt 2^{30}$, $r - l \gt 1$) — the minimum and maximum independence levels of the students. 32 33 Output 34 35 For each test case set, output three pairwise distinct integers $a, b$, and $c$, such that $l \le a, b, c \le r$ and the value of the expression $(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. 36 37 Example 38 39 Input 40 41 ``` 42 8 43 44 0 2 45 46 0 8 47 48 1 3 49 50 6 22 51 52 128 137 53 54 69 98 55 56 115 127 57 58 0 1073741823 59 ``` 60 61 Output 62 63 ``` 64 1 2 0 65 8 7 1 66 2 1 3 67 7 16 11 68 134 132 137 69 98 85 76 70 123 121 118 71 965321865 375544086 12551794 72 ``` 73 74 Note 75 76 In the first test case, the only suitable triplet of numbers ($a, b, c$) (up to permutation) is ($0, 1, 2$). 77 78 In the second test case, one of the suitable triplets is ($8, 7, 1$), where $(8 \oplus 7) + (7 \oplus 1) + (8 \oplus 1) = 15 + 6 + 9 = 30$. It can be shown that $30$ is the maximum possible value of $(a \oplus b) + (b \oplus c) + (a \oplus c)$ for $0 \le a, b, c \le 8$.