Codeforces In English По-русски criticalcoding Logout Home Top Catalog Contests Gym…
- User
Codeforces | In English По-русски criticalcoding | Logout
Home Top Catalog Contests Gym Problemset Groups Rating Edu API Calendar Help RayanHello 2025 Contest is running 00:00:15 Add to favourites → Score table Score Problem A 297 Problem B 594 Problem C 891 Problem D 1336 Problem E1 594 Problem E2 1188 Problem F 2078 Problem G 2226 Problem H 2672 Successful hack 100 Unsuccessful hack -50 Unsuccessful submission -50 Resubmission -50
-
If you solve problem on 02:07 from the first attempt
Problems Submit Code My Submissions Status Room Standings Custom Invocation
C. Trip to the Olympiad time limit per test 2 seconds memory limit per test 256 megabytes
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 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⊕b)+(b⊕c)+(a⊕c), where ⊕
denotes the bitwise XOR operation.
Your task is to choose any trio of students with the maximum possible team independence. Input
Each test contains multiple test cases. The first line contains a single integer t (1≤t≤104
) — the number of test cases. The description of the test cases follows.
The first line of each test case set contains two integers l and r (0≤l,r<230, r−l>1
) — the minimum and maximum independence levels of the students. Output
For each test case set, output three pairwise distinct integers a,b , and c, such that l≤a,b,c≤r and the value of the expression (a⊕b)+(b⊕c)+(a⊕c)
is maximized. If there are multiple triples with the maximum value, any of them can be output. Example Input Copy
8 0 2 0 8 1 3 6 22 128 137 69 98 115 127 0 1073741823
Output Copy
1 2 0 8 7 1 2 1 3 7 16 11 134 132 137 98 85 76 123 121 118 965321865 375544086 12551794
Note
In the first test case, the only suitable triplet of numbers (a,b,c ) (up to permutation) is (0,1,2
).
In the second test case, one of the suitable triplets is (8,7,1 ), where (8⊕7)+(7⊕1)+(8⊕1)=15+6+9=30. It can be shown that 30 is the maximum possible value of (a⊕b)+(b⊕c)+(a⊕c) for 0≤a,b,c≤8
.
Codeforces (c) Copyright 2010-2025 Mike Mirzayanov The only programming contests Web 2.0 platform Server time: Jan/04/2025 22:12:23UTC+5.5 (j1). Desktop version, switch to mobile version. Privacy Policy Supported by TON
-
- Assistant