Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B'You are given an array a consisting of n nonnegative integers. You can swap the elements at positions i and j if a_i~ mathsf{XOR}~a_j < 4 , where mathsf{XOR} is the bitwise XOR operation. Find the lexicographically smallest array that can be made with any number of swaps. An array x is lexicographically smaller than an array y if in the first position where x and y differ, x_i < y_i . The first line contains a single integer t ( 1 <= q t <= q 10^4 ) -- the number of test cases. The first line of each test case contains a single integer n ( 1 <= q n <= q 2 cdot10^5 ) -- the length of the array. The second line of each test case contains n integers a_i ( 0 <= q a_i <= q 10^9 ) -- the elements of the array. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case, output n integers -- the lexicographically smallest array that can be made with any number of swaps. For the first test case, you can swap any two elements, so we can produce the sorted array. For the second test case, you can swap 2 and 1 (their mathsf{XOR} is 3 ), 7 and 5 (their mathsf{XOR} is 2 ), and 7 and 6 (their mathsf{XOR} is 1 ) to get the lexicographically smallest array. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
263015943 |
masaftic |
G |
May 28, 2024, 1:15 p.m. |
OK |
C# 10 |
TESTS |
23 |
374 |
62156800 |
|
1400 |
263130377 |
masaftic |
G |
May 29, 2024, 11:07 a.m. |
OK |
C# 10 |
TESTS |
23 |
421 |
62054400 |
|
1400 |
263564482 |
LeMichael52 |
G |
June 1, 2024, 2:30 a.m. |
OK |
C# 10 |
TESTS |
23 |
609 |
49459200 |
|
1400 |
262372166 |
wangyiwen |
G |
May 24, 2024, 10:51 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
218 |
2662400 |
|
1400 |
262505810 |
jikong |
G |
May 25, 2024, 11:55 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
249 |
7884800 |
|
1400 |
262505939 |
luogu_bot5 |
G |
May 25, 2024, 11:56 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
280 |
7884800 |
|
1400 |
262413581 |
ImEquilibrium |
G |
May 24, 2024, 4:28 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
280 |
12288000 |
|
1400 |
262872677 |
OumaeKumimo |
G |
May 27, 2024, 11:38 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
296 |
11468800 |
|
1400 |
262296344 |
vucislav |
G |
May 23, 2024, 5:46 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
327 |
13926400 |
|
1400 |
262863875 |
sparsh__03 |
G |
May 27, 2024, 10:26 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
327 |
20275200 |
|
1400 |
262876614 |
dominator2003 |
G |
May 27, 2024, 12:06 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
359 |
8192000 |
|
1400 |
262327850 |
Ravindra_Rinwa |
G |
May 24, 2024, 3:15 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
374 |
8294400 |
|
1400 |
263155459 |
Soumik_M |
G |
May 29, 2024, 2:24 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
374 |
10547200 |
|
1400 |
262990997 |
CMiner |
G |
May 28, 2024, 9:51 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
155 |
6041600 |
|
1400 |
262798234 |
_Mugiwara_ |
G |
May 26, 2024, 8:05 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
171 |
2457600 |
|
1400 |
262893412 |
kazimiyuuka |
G |
May 27, 2024, 2:17 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
187 |
921600 |
|
1400 |
263523256 |
cpismylifeOwO |
G |
May 31, 2024, 4:02 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
187 |
1638400 |
|
1400 |
263034544 |
skmprohunt |
G |
May 28, 2024, 3:45 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
187 |
7372800 |
|
1400 |
262452864 |
Zack |
G |
May 25, 2024, 3:30 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
187 |
10035200 |
|
1400 |
262466739 |
paphangkon009 |
G |
May 25, 2024, 6:17 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
202 |
4403200 |
|
1400 |
262473062 |
Rachuu_uwu |
G |
May 25, 2024, 7:05 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
202 |
5939200 |
|
1400 |
263131930 |
idontknow233 |
G |
May 29, 2024, 11:19 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
202 |
8499200 |
|
1400 |
262259730 |
Amanydv0081 |
G |
May 23, 2024, 12:48 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
202 |
20377600 |
|
1400 |
262498513 |
GoldLight |
G |
May 25, 2024, 10:47 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
124 |
921600 |
|
1400 |
263092315 |
linweiyu1 |
G |
May 29, 2024, 5:57 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
124 |
3276800 |
|
1400 |
262712903 |
iamloser1100 |
G |
May 26, 2024, 1:53 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
139 |
2764800 |
|
1400 |
263566431 |
LeoChan2022 |
G |
June 1, 2024, 3:02 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
140 |
9625600 |
|
1400 |
262409823 |
ShadowDrunk |
G |
May 24, 2024, 3:55 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
156 |
10240000 |
|
1400 |
262336510 |
D_NATH |
G |
May 24, 2024, 5:21 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
218 |
19456000 |
|
1400 |
262979801 |
MrChronoJester |
G |
May 28, 2024, 8:15 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
218 |
39936000 |
|
1400 |
263146245 |
yasunny |
G |
May 29, 2024, 1:14 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
249 |
8192000 |
|
1400 |
263088568 |
Ackerlanna |
G |
May 29, 2024, 5:13 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
249 |
17305600 |
|
1400 |
262956455 |
Engineer |
G |
May 28, 2024, 4:39 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
265 |
16281600 |
|
1400 |
262929460 |
ivsnk |
G |
May 27, 2024, 7:52 p.m. |
OK |
Go |
TESTS |
23 |
264 |
23859200 |
|
1400 |
262418753 |
Avishkar_407 |
G |
May 24, 2024, 5:17 p.m. |
OK |
Go |
TESTS |
23 |
1875 |
40140800 |
|
1400 |
262638145 |
ItsLever |
G |
May 26, 2024, 2:26 a.m. |
OK |
Java 21 |
TESTS |
23 |
780 |
70041600 |
|
1400 |
262837619 |
d2s2 |
G |
May 27, 2024, 6:48 a.m. |
OK |
Java 21 |
TESTS |
23 |
1186 |
37068800 |
|
1400 |
263656406 |
OsamaNassar |
G |
June 1, 2024, 4:27 p.m. |
OK |
Java 21 |
TESTS |
23 |
1343 |
11776000 |
|
1400 |
262986747 |
.shinchan_ |
G |
May 28, 2024, 9:14 a.m. |
OK |
Java 8 |
TESTS |
23 |
593 |
43110400 |
|
1400 |
262874938 |
kl_2200031074 |
G |
May 27, 2024, 11:54 a.m. |
OK |
Java 8 |
TESTS |
23 |
1202 |
39628800 |
|
1400 |
263199282 |
nis1234 |
G |
May 30, 2024, 4:46 a.m. |
OK |
Java 8 |
TESTS |
23 |
1202 |
70041600 |
|
1400 |
262936103 |
arpit.mishra |
G |
May 27, 2024, 9:45 p.m. |
OK |
Java 8 |
TESTS |
23 |
1218 |
39628800 |
|
1400 |
262416908 |
PlayDate |
G |
May 24, 2024, 5 p.m. |
OK |
Java 8 |
TESTS |
23 |
1280 |
31539200 |
|
1400 |
262461103 |
Jha_coder1942 |
G |
May 25, 2024, 5:20 a.m. |
OK |
Java 8 |
TESTS |
23 |
1342 |
80998400 |
|
1400 |
263673242 |
Mr.1 |
G |
June 1, 2024, 7:03 p.m. |
OK |
Java 8 |
TESTS |
23 |
1484 |
36352000 |
|
1400 |
262656410 |
prex |
G |
May 26, 2024, 6:10 a.m. |
OK |
PyPy 3 |
TESTS |
23 |
593 |
30105600 |
|
1400 |
262430228 |
liu_ming |
G |
May 24, 2024, 7:17 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
280 |
45670400 |
|
1400 |
262642441 |
MistaFlash |
G |
May 26, 2024, 3:37 a.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
296 |
44236800 |
|
1400 |
262430084 |
liu_ming |
G |
May 24, 2024, 7:16 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
311 |
50995200 |
|
1400 |
262430129 |
liu_ming |
G |
May 24, 2024, 7:16 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
328 |
51097600 |
|
1400 |
262657019 |
prex |
G |
May 26, 2024, 6:15 a.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
358 |
44236800 |
|
1400 |
262426657 |
liu_ming |
G |
May 24, 2024, 6:36 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
359 |
62054400 |
|
1400 |
262891075 |
vwxyz0 |
G |
May 27, 2024, 1:58 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
390 |
46592000 |
|
1400 |
262891312 |
vwxyz0 |
G |
May 27, 2024, 2 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
421 |
46284800 |
|
1400 |
262426424 |
liu_ming |
G |
May 24, 2024, 6:33 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
437 |
67584000 |
|
1400 |
262870903 |
vwxyz0 |
G |
May 27, 2024, 11:24 a.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
484 |
46080000 |
|
1400 |
263095795 |
2210030057 |
G |
May 29, 2024, 6:29 a.m. |
OK |
Python 3 |
TESTS |
23 |
781 |
56115200 |
|
1400 |
262236386 |
2210080018 |
G |
May 23, 2024, 9:50 a.m. |
OK |
Python 3 |
TESTS |
23 |
796 |
56217600 |
|
1400 |
263409668 |
klu2100031976 |
G |
May 31, 2024, 4:37 a.m. |
OK |
Python 3 |
TESTS |
23 |
827 |
56217600 |
|
1400 |
262451668 |
Moyuhualuo |
G |
May 25, 2024, 3:13 a.m. |
OK |
Python 3 |
TESTS |
23 |
858 |
56115200 |
|
1400 |
263095233 |
mukund_s |
G |
May 29, 2024, 6:25 a.m. |
OK |
Python 3 |
TESTS |
23 |
890 |
56217600 |
|
1400 |
262446510 |
acoolhandle |
G |
May 25, 2024, 1:21 a.m. |
OK |
Python 3 |
TESTS |
23 |
984 |
55193600 |
|
1400 |
262701360 |
WarsNitin |
G |
May 26, 2024, 12:10 p.m. |
OK |
Python 3 |
TESTS |
23 |
1108 |
38502400 |
|
1400 |
262920889 |
DarkSky_0xFF |
G |
May 27, 2024, 6:12 p.m. |
OK |
Rust 2021 |
TESTS |
23 |
78 |
3174400 |
|
1400 |
262645084 |
SnowballSH |
G |
May 26, 2024, 3:56 a.m. |
OK |
Rust 2021 |
TESTS |
23 |
217 |
21401600 |
|
1400 |
remove filters
Back to search problems