Codeforces Round 1024 (Div. 1)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2101 Codeforces Round 1024 (Div. 1) FINISHED False 9000 29431523 May 11, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 6740 ) B Quartet Swapping PROGRAMMING data structures greedy sortings

You are given a permutation (a) of length (n)(^{\text{∗}}). You are allowed to do the following operation any number of times (possibly zero): Choose an index (1\le i\le n - 3). Then, swap (a_i) with (a_{i + 2}), and (a_{i + 1}) with (a_{i + 3}) simultaneously. In other words, permutation (a) will be transformed from (\ldots, a_i, a_{i+1}, a_{i+2}, a_{i+3}, \ldots) to (\ldots, a_{i+2}, a_{i+3}, a_{i}, a_{i+1}, \ldots). Determine the lexicographically smallest permutation(^{\text{†}}) that can be obtained by applying the above operation any number of times. (^{\text{∗}})A permutation of length (n) is an array consisting of (n) distinct integers from (1) to (n) in arbitrary order. For example, (2,3,1,5,4) is a permutation, but (1,2,2) is not a permutation ((2) appears twice in the array), and (1,3,4) is also not a permutation ((n=3) but there is (4) in the array). (^{\text{†}})An array (x) is lexicographically smaller than an array (y) of the same size if and only if the following holds: in the first position where (x) and (y) differ, the array (x) has a smaller element than the corresponding element in (y). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 1000)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((4\le n\le 2\cdot 10^5)) — the length of permutation (a). The second line contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \le a_i \le n)) — the elements of permutation (a). It is guaranteed that the sum of (n) over all test cases does not exceed (2\cdot 10^5). For each test case, output the lexicographically smallest permutation that can be obtained by applying the above operation any number of times. In the first test case, an operation can be done on index $$$i

Tutorials

142788

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
319329537 og.kostya B May 12, 2025, 5:25 a.m. OK C# 10 TESTS 31 202 27852800
319301423 timg8710 B May 11, 2025, 7:13 p.m. OK C++17 (GCC 7-32) TESTS 31 124 102400
319256381 Sid0309 B May 11, 2025, 3:40 p.m. OK C++17 (GCC 7-32) TESTS 31 124 102400
319326122 bqlp B May 12, 2025, 4:39 a.m. OK C++17 (GCC 7-32) TESTS 31 124 2457600
319233617 AliShahali1382 B May 11, 2025, 3:02 p.m. OK C++17 (GCC 7-32) TESTS 31 124 2457600
319290039 DanTheMan. B May 11, 2025, 5:02 p.m. OK C++17 (GCC 7-32) TESTS 31 140 102400
319282295 lwm7708 B May 11, 2025, 4:38 p.m. OK C++17 (GCC 7-32) TESTS 31 140 409600
319307534 vishal2045ks B May 11, 2025, 8:50 p.m. OK C++17 (GCC 7-32) TESTS 31 140 1331200
319237552 tzaph_ B May 11, 2025, 3:08 p.m. OK C++17 (GCC 7-32) TESTS 31 140 1433600
319234856 VAntonuk B May 11, 2025, 3:04 p.m. OK C++17 (GCC 7-32) TESTS 31 140 1945600
319326525 bqlp B May 12, 2025, 4:45 a.m. OK C++17 (GCC 7-32) TESTS 31 140 2457600
319327084 brendonw B May 12, 2025, 4:54 a.m. OK C++20 (GCC 13-64) TESTS 31 93 1331200
319238166 Hoks_ B May 11, 2025, 3:09 p.m. OK C++20 (GCC 13-64) TESTS 31 93 61132800
319224392 shiomusubi496 B May 11, 2025, 2:50 p.m. OK C++20 (GCC 13-64) TESTS 31 108 716800
319237137 ChengyunSun B May 11, 2025, 3:07 p.m. OK C++20 (GCC 13-64) TESTS 31 108 1638400
319325785 yeminghan B May 12, 2025, 4:33 a.m. OK C++20 (GCC 13-64) TESTS 31 108 1843200
319236752 flashmt B May 11, 2025, 3:07 p.m. OK C++20 (GCC 13-64) TESTS 31 109 0
319218858 tourist B May 11, 2025, 2:43 p.m. OK C++20 (GCC 13-64) TESTS 31 109 102400
319237494 Tuanlinh123 B May 11, 2025, 3:08 p.m. OK C++20 (GCC 13-64) TESTS 31 109 102400
319221700 Ormlis B May 11, 2025, 2:47 p.m. OK C++20 (GCC 13-64) TESTS 31 109 614400
319226424 zjy2008 B May 11, 2025, 2:53 p.m. OK C++20 (GCC 13-64) TESTS 31 109 819200
319319490 enslaved B May 12, 2025, 2:40 a.m. OK C++23 (GCC 14-64, msys2) TESTS 31 93 102400
319237753 w2y51c318 B May 11, 2025, 3:08 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 93 5427200
319232835 interlude B May 11, 2025, 3:01 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 93 10035200
319315613 TheYashB B May 12, 2025, 12:56 a.m. OK C++23 (GCC 14-64, msys2) TESTS 31 108 4812800
319318911 _Equinox B May 12, 2025, 2:27 a.m. OK C++23 (GCC 14-64, msys2) TESTS 31 109 0
319312630 Mamedov B May 11, 2025, 11:22 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 109 102400
319325709 Qzong B May 12, 2025, 4:32 a.m. OK C++23 (GCC 14-64, msys2) TESTS 31 109 102400
319243478 Laceprndpm B May 11, 2025, 3:17 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 109 102400
319305168 podumaru B May 11, 2025, 8:07 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 109 307200
319309501 bangan B May 11, 2025, 9:36 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 109 409600
319221204 hos.lyric B May 11, 2025, 2:46 p.m. OK D TESTS 31 358 16998400
319267046 pengin_2000 B May 11, 2025, 3:56 p.m. OK GNU C11 TESTS 31 202 5734400
319301123 rainboy B May 11, 2025, 7:09 p.m. OK GNU C11 TESTS 31 890 2457600
319291035 rainboy B May 11, 2025, 5:04 p.m. OK GNU C11 TESTS 31 905 3379200
319241022 ghj1222 B May 11, 2025, 3:13 p.m. OK GNU C11 TESTS 31 921 1433600
319325265 muradbhai B May 12, 2025, 4:25 a.m. OK GNU C11 TESTS 31 952 6451200
319324957 muradbhai B May 12, 2025, 4:19 a.m. OK GNU C11 TESTS 31 952 6451200
319273298 cyclop5 B May 11, 2025, 4:11 p.m. OK Go TESTS 31 124 13926400
319243936 Dominion948 B May 11, 2025, 3:18 p.m. OK Go TESTS 31 202 8089600
319240930 lyongwolf B May 11, 2025, 3:13 p.m. OK Java 21 TESTS 31 296 2150400
319231698 MadinaAlili B May 11, 2025, 2:59 p.m. OK Java 21 TESTS 31 390 4915200
319242233 Lilypad B May 11, 2025, 3:15 p.m. OK Java 21 TESTS 31 421 1024000
319260322 nathanballman B May 11, 2025, 3:44 p.m. OK Java 21 TESTS 31 453 1945600
319246134 rakshit2611 B May 11, 2025, 3:21 p.m. OK Java 21 TESTS 31 484 3174400
319238552 CyntaxError B May 11, 2025, 3:09 p.m. OK Java 21 TESTS 31 484 17612800
319304269 beedle B May 11, 2025, 7:54 p.m. OK Java 21 TESTS 31 749 7065600
319239994 golions B May 11, 2025, 3:11 p.m. OK Java 8 TESTS 31 343 5529600
319331454 kasiru_69 B May 12, 2025, 5:46 a.m. OK Java 8 TESTS 31 733 26726400
319255395 omdeshmukh1906 B May 11, 2025, 3:38 p.m. OK Java 8 TESTS 31 952 3993600
319228528 Tlatoani B May 11, 2025, 2:55 p.m. OK Kotlin 1.9 TESTS 31 514 12902400
319283887 Toinfinity B May 11, 2025, 4:43 p.m. OK PyPy 3 TESTS 31 577 21504000
319227742 bribritt B May 11, 2025, 2:54 p.m. OK PyPy 3-64 TESTS 31 203 31129600
319254012 Mukundan314 B May 11, 2025, 3:36 p.m. OK PyPy 3-64 TESTS 31 249 21811200
319304113 DarkTemplarDrop B May 11, 2025, 7:51 p.m. OK PyPy 3-64 TESTS 31 265 30822400
319238192 chinerist B May 11, 2025, 3:09 p.m. OK PyPy 3-64 TESTS 31 265 33382400
319241043 eepsilon B May 11, 2025, 3:13 p.m. OK PyPy 3-64 TESTS 31 280 23244800
319229714 golomb B May 11, 2025, 2:57 p.m. OK PyPy 3-64 TESTS 31 280 30822400
319238488 harurun4635 B May 11, 2025, 3:09 p.m. OK PyPy 3-64 TESTS 31 281 27545600
319221058 conqueror_of_tourist B May 11, 2025, 2:46 p.m. OK PyPy 3-64 TESTS 31 296 27750400
319234509 tassei903 B May 11, 2025, 3:03 p.m. OK PyPy 3-64 TESTS 31 296 36147200
319308438 DarkTemplarDrop B May 11, 2025, 9:11 p.m. OK PyPy 3-64 TESTS 31 311 27136000
319263331 Jimanbanashi B May 11, 2025, 3:48 p.m. OK Python 2 TESTS 31 781 12800000
319242588 shashanksp851 B May 11, 2025, 3:16 p.m. OK Python 3 TESTS 31 421 40038400
319233388 Taghi B May 11, 2025, 3:02 p.m. OK Python 3 TESTS 31 499 59289600
319223849 sansen B May 11, 2025, 2:49 p.m. OK Rust 2021 TESTS 31 93 7884800
319231442 darkkcyan B May 11, 2025, 2:59 p.m. OK Rust 2021 TESTS 31 140 12185600
319226612 Egor B May 11, 2025, 2:53 p.m. OK Rust 2021 TESTS 31 155 3584000
319238489 DanielAnker B May 11, 2025, 3:09 p.m. OK Rust 2021 TESTS 31 171 7065600

remove filters

Back to search problems