Codeforces Round 1062 (Div. 4)

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
2167 Codeforces Round 1062 (Div. 4) FINISHED False 8100 14743523 Oct. 28, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 35775 ) C Isamatdin and His Magic Wand! PROGRAMMING constructive algorithms greedy implementation sortings

Isamatdin has (n) toys arranged in a row. The (i)-th toy has an integer (a_i). He wanted to sort them because otherwise, his mother would scold him. However, Isamatdin never liked arranging toys in order, so his friend JahonaliX gave him a magic wand to help. Unfortunately, JahonaliX made a small mistake while creating the wand. But Isamatdin couldn't wait any longer and decided to use the broken wand anyway. The wand can only swap two toys if their integers have different parity (one is even, the other is odd). In other words, you can swap toys in positions ((i, j)) only if (a_i \bmod 2 \neq a_j \bmod 2), where (\bmod) — is the remainder of integer division. Now he wants to know the lexicographically smallest (^{\text{∗}}) arrangement he can achieve using this broken wand. (^{\text{∗}})A sequence (p) is lexicographically smaller than a sequence (q) if there exists an index (i) such that (p_j = q_j) for all (j < i), and (p_i < q_i). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((1 \le n \le 2 \cdot 10^5)) — the number of toys. The second line of each test case contains (n) integers (a_1, a_2, \dots, a_n) ((1 \le a_i \le 10^9)) — the integers of the toys. 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 sequence that can be obtained using the described operation. In the first test case, we can swap positions ((1, 3)) and then ((2, 3)). In the second test case, we can swap positions ((1, 2)), ((1, 3)), and then ((2, 3)). In the third and fourth test cases, we can't swap any positions because all toy integers have the same parity.

Tutorials

Arpa Video Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
346559095 darkphoenix2208 C Oct. 30, 2025, 3:32 a.m. OK C++17 (GCC 7-32) TESTS 10 108 0
346499634 Golden_Pheonix C Oct. 29, 2025, 4:34 p.m. OK C++17 (GCC 7-32) TESTS 10 108 0
346489600 Aktian C Oct. 29, 2025, 3:35 p.m. OK C++17 (GCC 7-32) TESTS 10 108 0
346384585 afutik C Oct. 28, 2025, 9:20 p.m. OK C++17 (GCC 7-32) TESTS 10 108 0
346406531 Ravi_Kumar_Gupta C Oct. 29, 2025, 4 a.m. OK C++17 (GCC 7-32) TESTS 10 108 102400
346415549 Lactealsubstance C Oct. 29, 2025, 5:46 a.m. OK C++17 (GCC 7-32) TESTS 10 108 819200
346569643 abhisheksinghdhangar C Oct. 30, 2025, 5:20 a.m. OK C++17 (GCC 7-32) TESTS 10 109 0
346566917 dbywsc C Oct. 30, 2025, 4:52 a.m. OK C++17 (GCC 7-32) TESTS 10 109 0
346559439 NMHNhan24120399 C Oct. 30, 2025, 3:36 a.m. OK C++17 (GCC 7-32) TESTS 10 109 0
346548526 Denge C Oct. 30, 2025, 1:30 a.m. OK C++17 (GCC 7-32) TESTS 10 109 0
346408879 _andyli C Oct. 29, 2025, 4:31 a.m. OK C++20 (GCC 13-64) TESTS 10 62 2150400
346397276 _swaroop_0307 C Oct. 29, 2025, 1:32 a.m. OK C++20 (GCC 13-64) TESTS 10 78 0
346538530 _Mahmoud_Ali_ C Oct. 29, 2025, 9:53 p.m. OK C++20 (GCC 13-64) TESTS 10 78 102400
346390128 tahmidarefin C Oct. 28, 2025, 10:09 p.m. OK C++20 (GCC 13-64) TESTS 10 78 819200
346380290 niloy_acharjee C Oct. 28, 2025, 8:19 p.m. OK C++20 (GCC 13-64) TESTS 10 92 0
346572203 droxx C Oct. 30, 2025, 5:45 a.m. OK C++20 (GCC 13-64) TESTS 10 93 0
346566910 slowtyp3 C Oct. 30, 2025, 4:52 a.m. OK C++20 (GCC 13-64) TESTS 10 93 0
346564196 cpverse C Oct. 30, 2025, 4:21 a.m. OK C++20 (GCC 13-64) TESTS 10 93 0
346561954 LuOH3_ C Oct. 30, 2025, 4:08 a.m. OK C++20 (GCC 13-64) TESTS 10 93 0
346560285 broken_code C Oct. 30, 2025, 3:47 a.m. OK C++20 (GCC 13-64) TESTS 10 93 0
346574448 M0ZA7ER C Oct. 30, 2025, 6:06 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
346573016 keeshu C Oct. 30, 2025, 5:52 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
346571017 roni126 C Oct. 30, 2025, 5:34 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
346570464 Benzn C Oct. 30, 2025, 5:28 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
346570162 Mohamed_Shosha C Oct. 30, 2025, 5:25 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
346569792 _anant_ranjan C Oct. 30, 2025, 5:22 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
346569670 motomoto0001 C Oct. 30, 2025, 5:21 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
346565997 dishsoap C Oct. 30, 2025, 4:42 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
346564937 prashantkumarsharma5911 C Oct. 30, 2025, 4:30 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
346564701 RealAni C Oct. 30, 2025, 4:27 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
346558412 irf_2246 C Oct. 30, 2025, 3:25 a.m. OK GNU C11 TESTS 10 921 1638400
346517557 imranbinhafiz C Oct. 29, 2025, 6:14 p.m. OK GNU C11 TESTS 10 921 1638400
346522521 luckykumar232727 C Oct. 29, 2025, 6:49 p.m. OK GNU C11 TESTS 10 936 1638400
346485621 Mysni C Oct. 29, 2025, 3:12 p.m. OK GNU C11 TESTS 10 1015 1638400
346487353 abdullahelshebrawy C Oct. 29, 2025, 3:23 p.m. OK Go TESTS 10 171 4710400
346525574 DeymosX C Oct. 29, 2025, 7:15 p.m. OK Go TESTS 10 202 4710400
346514897 SigVist C Oct. 29, 2025, 5:57 p.m. OK Go TESTS 10 1983 5017600
346489266 korntest C Oct. 29, 2025, 3:34 p.m. OK Haskell TESTS 10 1546 93491200
346561559 minibin C Oct. 30, 2025, 4:03 a.m. OK Java 21 TESTS 10 296 819200
346397408 ccj123 C Oct. 29, 2025, 1:35 a.m. OK Java 21 TESTS 10 296 1126400
346500954 klu2300030753 C Oct. 29, 2025, 4:42 p.m. OK Java 21 TESTS 10 296 1331200
346506932 VaHiX C Oct. 29, 2025, 5:10 p.m. OK Java 21 TESTS 10 311 819200
346409364 sathwikhbhat C Oct. 29, 2025, 4:37 a.m. OK Java 21 TESTS 10 358 921600
346533662 sallatejaswi C Oct. 29, 2025, 8:37 p.m. OK Java 21 TESTS 10 406 1638400
346413042 dineshdcoc C Oct. 29, 2025, 5:19 a.m. OK Java 21 TESTS 10 453 20889600
346515461 numbers0689 C Oct. 29, 2025, 6 p.m. OK Java 21 TESTS 10 624 1024000
346572382 NooB__C0der C Oct. 30, 2025, 5:47 a.m. OK Java 21 TESTS 10 655 1536000
346487850 KazutoNWB C Oct. 29, 2025, 3:25 p.m. OK Java 21 TESTS 10 655 24678400
346529474 sarthaKKharKa_18 C Oct. 29, 2025, 7:53 p.m. OK Java 8 TESTS 10 171 0
346414261 lupunish C Oct. 29, 2025, 5:33 a.m. OK Java 8 TESTS 10 233 4300800
346406760 kartikdhande772 C Oct. 29, 2025, 4:03 a.m. OK Java 8 TESTS 10 265 3788800
346525982 NeelmaniPandey09 C Oct. 29, 2025, 7:19 p.m. OK Java 8 TESTS 10 764 0
346509559 KrisnhnaSrivastava C Oct. 29, 2025, 5:25 p.m. OK Java 8 TESTS 10 764 19251200
346574250 dhinesh_J C Oct. 30, 2025, 6:04 a.m. OK Java 8 TESTS 10 765 0
346552163 pranavarajput5555 C Oct. 30, 2025, 2:20 a.m. OK Java 8 TESTS 10 780 0
346511320 akshita_0802 C Oct. 29, 2025, 5:35 p.m. OK Java 8 TESTS 10 780 0
346501926 javeed_123 C Oct. 29, 2025, 4:48 p.m. OK Java 8 TESTS 10 780 0
346522231 Ram4365 C Oct. 29, 2025, 6:47 p.m. OK Java 8 TESTS 10 781 0
346517177 VaHiX C Oct. 29, 2025, 6:11 p.m. OK Kotlin 2.2 TESTS 10 718 13414400
346517288 re-l_no_tamago C Oct. 29, 2025, 6:12 p.m. OK Node.js TESTS 10 249 69324800
346524161 mosaab20111 C Oct. 29, 2025, 7:03 p.m. OK Perl TESTS 10 358 28672000
346526403 Georgy_Hryashev C Oct. 29, 2025, 7:23 p.m. OK PyPy 3 TESTS 10 608 19353600
346400641 makimakimakki C Oct. 29, 2025, 2:35 a.m. OK PyPy 3 TESTS 10 624 19046400
346487684 Pingo_does_coding C Oct. 29, 2025, 3:24 p.m. OK PyPy 3 TESTS 10 639 18329600
346551152 mo-hit C Oct. 30, 2025, 2:11 a.m. OK PyPy 3 TESTS 10 640 19763200
346407050 Khoatrandinh C Oct. 29, 2025, 4:07 a.m. OK PyPy 3 TESTS 10 671 19456000
346553703 Presi028 C Oct. 30, 2025, 2:34 a.m. OK PyPy 3 TESTS 10 671 19763200
346457197 NTT_DAL C Oct. 29, 2025, 11:55 a.m. OK PyPy 3 TESTS 10 686 18227200
346487284 kuanc C Oct. 29, 2025, 3:22 p.m. OK PyPy 3 TESTS 10 687 18841600
346383652 jared.mccarthy05 C Oct. 28, 2025, 9:04 p.m. OK PyPy 3 TESTS 10 796 19148800
346488641 pusheen_1024 C Oct. 29, 2025, 3:30 p.m. OK PyPy 3-64 TESTS 10 156 21708800
346507943 VaHiX C Oct. 29, 2025, 5:16 p.m. OK PyPy 3-64 TESTS 10 171 27033600
346411968 Sumeet_Sharma_01 C Oct. 29, 2025, 5:08 a.m. OK PyPy 3-64 TESTS 10 171 29491200
346390203 sarang.n.m C Oct. 28, 2025, 10:11 p.m. OK PyPy 3-64 TESTS 10 186 26214400
346525960 vindhya.1110 C Oct. 29, 2025, 7:19 p.m. OK PyPy 3-64 TESTS 10 187 23142400
346508735 suryanshmishra.0904 C Oct. 29, 2025, 5:20 p.m. OK PyPy 3-64 TESTS 10 187 25190400
346501479 mrxe C Oct. 29, 2025, 4:45 p.m. OK PyPy 3-64 TESTS 10 187 26931200
346556717 SirMrGuy C Oct. 30, 2025, 3:04 a.m. OK PyPy 3-64 TESTS 10 202 23040000
346396904 rank007 C Oct. 29, 2025, 1:25 a.m. OK PyPy 3-64 TESTS 10 202 26624000
346547952 VIRUSGAMING C Oct. 30, 2025, 1:19 a.m. OK PyPy 3-64 TESTS 10 202 26828800
346408716 tekka_ity C Oct. 29, 2025, 4:29 a.m. OK Python 3 TESTS 10 187 27033600
346393410 rip4inskiy C Oct. 28, 2025, 11:50 p.m. OK Python 3 TESTS 10 202 28876800
346397029 fresh-breeze C Oct. 29, 2025, 1:27 a.m. OK Python 3 TESTS 10 203 27033600
346528124 ctrl--akshit C Oct. 29, 2025, 7:40 p.m. OK Python 3 TESTS 10 234 27136000
346381789 ankitbodh5 C Oct. 28, 2025, 8:36 p.m. OK Python 3 TESTS 10 234 27340800
346510587 tringuyen2k7 C Oct. 29, 2025, 5:31 p.m. OK Python 3 TESTS 10 234 28672000
346547508 Pretextor C Oct. 30, 2025, 1:10 a.m. OK Python 3 TESTS 10 249 27033600
346407416 deadmeme C Oct. 29, 2025, 4:12 a.m. OK Python 3 TESTS 10 249 27238400
346392555 shivangkeshri3 C Oct. 28, 2025, 11:22 p.m. OK Python 3 TESTS 10 249 28876800
346502492 harizibam_v C Oct. 29, 2025, 4:51 p.m. OK Python 3 TESTS 10 265 27340800

remove filters

Back to search problems