Codeforces Round 1083 (Div. 2)

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
2205 Codeforces Round 1083 (Div. 2) FINISHED False 9000 4289123 Feb. 26, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 16857 ) A Simons and Making It Beautiful PROGRAMMING brute force constructive algorithms

For a permutation(^{\text{∗}}) (r) of length (m), we call an index (i) ((1\le i\le m)) ugly if and only if (i=\max(\{r_1,r_2,\ldots,r_i\})). Simons has a permutation (p) of length (n), and he can perform the following operation on (p) at most once : Choose two indices (i) and (j) ((1\le i\ne j\le n)), then swap (p_i) and (p_j). Find a permutation (q) that can be obtained from (p) by performing the above operation at most once, such that the number of ugly indices in (q) is minimized. (^{\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). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 100)). The description of the test cases follows. The first line contains an integer (n) ((1\le n\le 500)) — the length of (p). The second line contains (n) integers (p_1,p_2,\ldots,p_n) ((1\le p_i\le n), all (p_i)-s are distinct) — the elements of (p). For each test case, print (n) integers (q_1,q_2,\ldots,q_n) — the permutation you found. If there are multiple possible permutations, you may output any. In the first test case, Simons can obtain only two possible permutations: (1,2) and (2,1). For permutation (1,2), we can see (1=\max(\{1\})) and (2=\max(\{1,2\})). So there are two ugly indices. For permutation (2,1), we can see (1\ne\max(\{2\})) and (2=\max(\{2,1\})). So there is only one ugly index. Thus, permutation (2,1) has the minimum count of ugly indices. In the second test case, Simons can obtain permutation (2,4,1,3) by choosing indices $$$2$

Tutorials

Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
364564162 nksammirPL A Feb. 26, 2026, 9:09 p.m. OK C# 13 TESTS 4 62 512000
364559662 Labantch A Feb. 26, 2026, 8:14 p.m. OK C# 13 TESTS 4 62 1638400
364535214 KhairulIX A Feb. 26, 2026, 4:33 p.m. OK C# 13 TESTS 4 62 13209600
364532669 tusharthecoder A Feb. 26, 2026, 4:21 p.m. OK C# 13 TESTS 4 78 2867200
364590311 smitr5097 A Feb. 27, 2026, 5:55 a.m. OK C++17 (GCC 7-32) TESTS 4 15 0
364587145 amitkr_nitdgp A Feb. 27, 2026, 5:09 a.m. OK C++17 (GCC 7-32) TESTS 4 15 0
364558121 AAFouad A Feb. 26, 2026, 7:57 p.m. OK C++17 (GCC 7-32) TESTS 4 15 0
364557693 uiarafat02 A Feb. 26, 2026, 7:54 p.m. OK C++17 (GCC 7-32) TESTS 4 15 0
364554053 SHREYANSHJAIN A Feb. 26, 2026, 7:12 p.m. OK C++17 (GCC 7-32) TESTS 4 15 0
364548925 alrifatsabbir A Feb. 26, 2026, 6:18 p.m. OK C++17 (GCC 7-32) TESTS 4 15 0
364548531 Titan_W A Feb. 26, 2026, 6:15 p.m. OK C++17 (GCC 7-32) TESTS 4 15 0
364547699 atharva_777 A Feb. 26, 2026, 6:07 p.m. OK C++17 (GCC 7-32) TESTS 4 15 0
364544763 VELDORA57 A Feb. 26, 2026, 5:39 p.m. OK C++17 (GCC 7-32) TESTS 4 15 0
364536405 bah_ar14 A Feb. 26, 2026, 4:38 p.m. OK C++17 (GCC 7-32) TESTS 4 15 0
364588363 jiuxun9x A Feb. 27, 2026, 5:28 a.m. OK C++20 (GCC 13-64) TESTS 4 15 0
364587844 M7mdKady14 A Feb. 27, 2026, 5:21 a.m. OK C++20 (GCC 13-64) TESTS 4 15 0
364587623 FarSpawn A Feb. 27, 2026, 5:17 a.m. OK C++20 (GCC 13-64) TESTS 4 15 0
364578524 woncharrrrr A Feb. 27, 2026, 2:30 a.m. OK C++20 (GCC 13-64) TESTS 4 15 0
364577511 Zmeiying_china A Feb. 27, 2026, 2:11 a.m. OK C++20 (GCC 13-64) TESTS 4 15 0
364574820 Shivam055 A Feb. 27, 2026, 1 a.m. OK C++20 (GCC 13-64) TESTS 4 15 0
364574727 HeroZEXAL A Feb. 27, 2026, 12:58 a.m. OK C++20 (GCC 13-64) TESTS 4 15 0
364574450 xiaojuruo_haokee A Feb. 27, 2026, 12:50 a.m. OK C++20 (GCC 13-64) TESTS 4 15 0
364561472 LoL70 A Feb. 26, 2026, 8:34 p.m. OK C++20 (GCC 13-64) TESTS 4 15 0
364561044 The_Ghost_ALI A Feb. 26, 2026, 8:30 p.m. OK C++20 (GCC 13-64) TESTS 4 15 0
364522607 pandeyy.0 A Feb. 26, 2026, 3:44 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 0 0
364590616 Mabingnan__V A Feb. 27, 2026, 5:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 15 0
364589966 Aman_g192 A Feb. 27, 2026, 5:51 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 15 0
364586997 Vivek_Pandey_ A Feb. 27, 2026, 5:07 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 15 0
364586721 K-D-2005 A Feb. 27, 2026, 5:03 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 15 0
364586563 HetanshiPoriya A Feb. 27, 2026, 5 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 15 0
364585929 aryandhameliya10 A Feb. 27, 2026, 4:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 15 0
364585017 leon_1 A Feb. 27, 2026, 4:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 15 0
364584840 ShivamKrTiwari A Feb. 27, 2026, 4:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 15 0
364584198 Vijay_9848 A Feb. 27, 2026, 4:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 15 0
364584681 ChuanxNi A Feb. 27, 2026, 4:26 a.m. OK GNU C11 TESTS 4 78 0
364588314 DaeSu A Feb. 27, 2026, 5:27 a.m. OK GNU C11 TESTS 4 93 0
364541980 Kartheeeeek A Feb. 26, 2026, 5:02 p.m. OK GNU C11 TESTS 4 93 0
364531303 ark67 A Feb. 26, 2026, 4:15 p.m. OK GNU C11 TESTS 4 93 0
364530379 suryavardhan7959 A Feb. 26, 2026, 4:12 p.m. OK GNU C11 TESTS 4 93 0
364525580 Codingking48 A Feb. 26, 2026, 3:54 p.m. OK GNU C11 TESTS 4 93 0
364524899 Mk05_CF A Feb. 26, 2026, 3:52 p.m. OK GNU C11 TESTS 4 93 0
364521954 sazzad59 A Feb. 26, 2026, 3:42 p.m. OK GNU C11 TESTS 4 93 0
364538268 anik_2 A Feb. 26, 2026, 4:46 p.m. OK GNU C11 TESTS 4 93 102400
364548848 Meenakshi-07 A Feb. 26, 2026, 6:17 p.m. OK GNU C11 TESTS 4 109 0
364536070 irahensa A Feb. 26, 2026, 4:36 p.m. OK Go TESTS 4 62 1126400
364568355 alkhwarizmii A Feb. 26, 2026, 10:21 p.m. OK Go TESTS 4 62 2150400
364540672 shaik.imran9916001578 A Feb. 26, 2026, 4:57 p.m. OK Java 21 TESTS 4 140 0
364530592 sreenikar7 A Feb. 26, 2026, 4:12 p.m. OK Java 21 TESTS 4 156 0
364588453 aranjhevyi_babochka A Feb. 27, 2026, 5:30 a.m. OK Java 21 TESTS 4 171 0
364529348 sidgureja A Feb. 26, 2026, 4:07 p.m. OK Java 21 TESTS 4 171 0
364537582 Rbeare A Feb. 26, 2026, 4:43 p.m. OK Java 21 TESTS 4 171 716800
364532406 ritish33 A Feb. 26, 2026, 4:20 p.m. OK Java 21 TESTS 4 187 0
364528607 cs23341A05D5 A Feb. 26, 2026, 4:05 p.m. OK Java 21 TESTS 4 187 204800
364526382 Ritika_Pandey A Feb. 26, 2026, 3:56 p.m. OK Java 21 TESTS 4 187 512000
364588099 sulabhambule A Feb. 27, 2026, 5:24 a.m. OK Java 21 TESTS 4 187 716800
364585586 kishanbhadra A Feb. 27, 2026, 4:43 a.m. OK Java 21 TESTS 4 187 716800
364588810 public-static-void-main A Feb. 27, 2026, 5:35 a.m. OK Java 8 TESTS 4 109 16896000
364588224 trimoyee_ghosh A Feb. 27, 2026, 5:26 a.m. OK Java 8 TESTS 4 125 0
364537294 iamdns A Feb. 26, 2026, 4:42 p.m. OK Java 8 TESTS 4 125 0
364533175 jms_luck A Feb. 26, 2026, 4:23 p.m. OK Java 8 TESTS 4 125 0
364566575 hetshah16 A Feb. 26, 2026, 9:45 p.m. OK Java 8 TESTS 4 140 0
364530019 nandhika66 A Feb. 26, 2026, 4:10 p.m. OK Java 8 TESTS 4 140 0
364529255 yukthasiri25 A Feb. 26, 2026, 4:07 p.m. OK Java 8 TESTS 4 140 0
364528263 vv12388 A Feb. 26, 2026, 4:03 p.m. OK Java 8 TESTS 4 140 0
364526440 dinesh3000 A Feb. 26, 2026, 3:57 p.m. OK Java 8 TESTS 4 140 0
364524954 AnkushSil A Feb. 26, 2026, 3:52 p.m. OK Java 8 TESTS 4 140 0
364523172 navya_yadav A Feb. 26, 2026, 3:46 p.m. OK Kotlin 1.7 TESTS 4 281 102400
364529791 sajjanikhil123 A Feb. 26, 2026, 4:09 p.m. OK Kotlin 1.9 TESTS 4 109 0
364560375 dean.me1 A Feb. 26, 2026, 8:22 p.m. OK PyPy 3 TESTS 4 62 3174400
364569952 Jyotier A Feb. 26, 2026, 11 p.m. OK PyPy 3 TESTS 4 78 2867200
364530561 aluuu_ A Feb. 26, 2026, 4:12 p.m. OK PyPy 3 TESTS 4 93 2764800
364549814 shdwnvrmr A Feb. 26, 2026, 6:26 p.m. OK PyPy 3 TESTS 4 93 2867200
364523399 Dharanidharram A Feb. 26, 2026, 3:47 p.m. OK PyPy 3 TESTS 4 93 2867200
364571239 Jhinigami A Feb. 26, 2026, 11:32 p.m. OK PyPy 3 TESTS 4 109 3686400
364525516 chi__chu A Feb. 26, 2026, 3:54 p.m. OK PyPy 3-64 TESTS 4 46 1638400
364522178 krishkothari A Feb. 26, 2026, 3:43 p.m. OK PyPy 3-64 TESTS 4 46 1638400
364580269 U.. A Feb. 27, 2026, 3:02 a.m. OK PyPy 3-64 TESTS 4 46 2150400
364551142 anasdharar A Feb. 26, 2026, 6:40 p.m. OK PyPy 3-64 TESTS 4 46 2150400
364551428 WickedLordShingan A Feb. 26, 2026, 6:43 p.m. OK PyPy 3-64 TESTS 4 46 2252800
364550062 learnerdaily5 A Feb. 26, 2026, 6:28 p.m. OK PyPy 3-64 TESTS 4 46 2252800
364583096 bharathkarthik A Feb. 27, 2026, 3:55 a.m. OK PyPy 3-64 TESTS 4 46 2355200
364589178 bathinishashipreetham03 A Feb. 27, 2026, 5:40 a.m. OK PyPy 3-64 TESTS 4 46 3276800
364563167 mawo78 A Feb. 26, 2026, 8:55 p.m. OK PyPy 3-64 TESTS 4 46 3379200
364557654 Friedrich A Feb. 26, 2026, 7:53 p.m. OK PyPy 3-64 TESTS 4 46 3379200
364531361 SaraZeynalzada A Feb. 26, 2026, 4:16 p.m. OK Python 2 TESTS 4 46 0
364530614 Oskar_Kinell A Feb. 26, 2026, 4:13 p.m. OK Python 3 TESTS 4 31 307200
364539815 U-K-06 A Feb. 26, 2026, 4:53 p.m. OK Python 3 TESTS 4 31 409600
364533844 ASLucky A Feb. 26, 2026, 4:26 p.m. OK Python 3 TESTS 4 31 512000
364531262 Anisha_2702 A Feb. 26, 2026, 4:15 p.m. OK Python 3 TESTS 4 31 716800
364550563 na24b004 A Feb. 26, 2026, 6:33 p.m. OK Python 3 TESTS 4 46 409600
364535479 mowan75 A Feb. 26, 2026, 4:34 p.m. OK Python 3 TESTS 4 46 409600
364529199 bigboi_td A Feb. 26, 2026, 4:07 p.m. OK Python 3 TESTS 4 46 409600
364526659 Ezh1k A Feb. 26, 2026, 3:57 p.m. OK Python 3 TESTS 4 46 409600
364524855 DevaSriD A Feb. 26, 2026, 3:51 p.m. OK Python 3 TESTS 4 46 409600
364540722 anitha_desetti A Feb. 26, 2026, 4:57 p.m. OK Python 3 TESTS 4 46 512000
364534225 CoHHa9_MyXa A Feb. 26, 2026, 4:28 p.m. OK Rust 2024 TESTS 4 31 0

remove filters

Back to search problems