Codeforces Round 798 (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
1689 Codeforces Round 798 (Div. 2) FINISHED False 7200 82301063 June 10, 2022, 4:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 17838 ) B Mystic Permutation PROGRAMMING data structures greedy implementation

B"Monocarp is a little boy who lives in Byteland and he loves programming. Recently, he found a permutation of length n . He has to come up with a mystic permutation. It has to be a new permutation such that it differs from the old one in each position. More formally, if the old permutation is p_1,p_2, ldots,p_n and the new one is q_1,q_2, ldots,q_n it must hold that p_1 neq q_1, p_2 neq q_2, ldots ,p_n neq q_n. Monocarp is afraid of lexicographically large permutations. Can you please help him to find the lexicographically minimal mystic permutation? There are several test cases in the input data. The first line contains a single integer t ( 1 <= q t <= q 200 ) -- the number of test cases. This is followed by the test cases description. The first line of each test case contains a positive integer n ( 1 <= q n <= q 1000 ) -- the length of the permutation. The second line of each test case contains n distinct positive integers p_1, p_2, ldots, p_n ( 1 <= q p_i <= q n ). It's guaranteed that p is a permutation, i. e. p_i neq p_j for all i neq j . It is guaranteed that the sum of n does not exceed 1000 over all test cases. For each test case, output n positive integers -- the lexicographically minimal mystic permutations. If such a permutation does not exist, output -1 instead. In the first test case possible permutations that are mystic are [2,3,1] and [3,1,2] . Lexicographically smaller of the two is [2,3,1] . In the second test case, [1,2,3,4,5] is the lexicographically minimal permutation and it is also mystic. In third test case possible mystic permutations are [1,2,4,3] , [1,4,2,3] , [1,4,3,2] , [3,1,4,2] , [3,2,4,1] , [3,4,2,1] , [4,1,2,3] , [4,1,3,2] and [4,3,2,1] . The smallest one is [1,2,4,3] . "...

Tutorials

Editorial for Codeforces Round #798 (Div. 2)

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
160145952 ansergeyg B June 10, 2022, 8:46 p.m. OK C# 8 TESTS 12 93 716800
160165158 shanu11223 B June 11, 2022, 5:49 a.m. OK GNU C11 TESTS 12 15 0
160145113 dhruv21 B June 10, 2022, 8:30 p.m. OK GNU C11 TESTS 12 15 0
160153306 Aisha993 B June 11, 2022, 1:32 a.m. OK GNU C11 TESTS 12 15 0
160153387 SAFIN07 B June 11, 2022, 1:35 a.m. OK GNU C11 TESTS 12 15 0
160143914 GTrigger B June 10, 2022, 8:07 p.m. OK GNU C11 TESTS 12 15 0
160144016 Jahir10 B June 10, 2022, 8:09 p.m. OK GNU C11 TESTS 12 15 0
160132054 abusayeid B June 10, 2022, 6:24 p.m. OK GNU C11 TESTS 12 31 0
160158721 samim_ahmed B June 11, 2022, 4:01 a.m. OK GNU C11 TESTS 12 31 0
160127303 Kel_Mahmut B June 10, 2022, 6:08 p.m. OK GNU C11 TESTS 12 31 0
160141013 tushar_kumar B June 10, 2022, 7:28 p.m. OK GNU C++14 TESTS 12 0 0
160140513 Caforce B June 10, 2022, 7:23 p.m. OK GNU C++14 TESTS 12 0 0
160164933 navi_here B June 11, 2022, 5:46 a.m. OK GNU C++14 TESTS 12 0 0
160158895 hardy_9795 B June 11, 2022, 4:05 a.m. OK GNU C++14 TESTS 12 0 0
160158349 Kicamon B June 11, 2022, 3:53 a.m. OK GNU C++14 TESTS 12 0 0
160157102 refain B June 11, 2022, 3:22 a.m. OK GNU C++14 TESTS 12 0 0
160155543 harsh_9c B June 11, 2022, 2:44 a.m. OK GNU C++14 TESTS 12 0 0
160165541 kulshr_0207 B June 11, 2022, 5:54 a.m. OK GNU C++14 TESTS 12 0 0
160144222 Heartlessplaye B June 10, 2022, 8:13 p.m. OK GNU C++14 TESTS 12 0 0
160142484 Ahsanul_Anam_4632 B June 10, 2022, 7:46 p.m. OK GNU C++14 TESTS 12 0 0
160154122 trungdc2003 B June 11, 2022, 2:01 a.m. OK GNU C++17 TESTS 12 0 0
160165190 vasu3445 B June 11, 2022, 5:50 a.m. OK GNU C++17 TESTS 12 0 0
160160074 CherryFrog B June 11, 2022, 4:28 a.m. OK GNU C++17 TESTS 12 0 0
160156873 shoaib.gondal B June 11, 2022, 3:17 a.m. OK GNU C++17 TESTS 12 0 0
160156226 j__prakhar B June 11, 2022, 3:01 a.m. OK GNU C++17 TESTS 12 0 0
160155813 hossain_234 B June 11, 2022, 2:51 a.m. OK GNU C++17 TESTS 12 0 0
160155601 femvpliet B June 11, 2022, 2:45 a.m. OK GNU C++17 TESTS 12 0 0
160155527 xuewuguai B June 11, 2022, 2:43 a.m. OK GNU C++17 TESTS 12 0 0
160154592 Amouss B June 11, 2022, 2:16 a.m. OK GNU C++17 TESTS 12 0 0
160154566 abhash6406 B June 11, 2022, 2:16 a.m. OK GNU C++17 TESTS 12 0 0
160162072 smagarwal B June 11, 2022, 5:03 a.m. OK GNU C++17 (64) TESTS 12 0 0
160165989 Antonyan B June 11, 2022, 6 a.m. OK GNU C++17 (64) TESTS 12 0 0
160164668 whohet B June 11, 2022, 5:42 a.m. OK GNU C++17 (64) TESTS 12 0 0
160164623 Pradeepbeginner B June 11, 2022, 5:41 a.m. OK GNU C++17 (64) TESTS 12 0 0
160163389 FAILURE. B June 11, 2022, 5:23 a.m. OK GNU C++17 (64) TESTS 12 0 0
160162730 GudeGude B June 11, 2022, 5:13 a.m. OK GNU C++17 (64) TESTS 12 0 0
160161390 mcj201314 B June 11, 2022, 4:52 a.m. OK GNU C++17 (64) TESTS 12 0 0
160154789 Zeardoe B June 11, 2022, 2:23 a.m. OK GNU C++17 (64) TESTS 12 0 0
160152067 strange757 B June 11, 2022, 12:39 a.m. OK GNU C++17 (64) TESTS 12 0 0
160146447 Einestine B June 10, 2022, 8:58 p.m. OK GNU C++17 (64) TESTS 12 0 0
160160921 Tsne B June 11, 2022, 4:44 a.m. OK GNU C++20 (64) TESTS 12 0 0
160161157 daniyar-is-019_er-2025 B June 11, 2022, 4:48 a.m. OK GNU C++20 (64) TESTS 12 0 0
160161424 sriyk009 B June 11, 2022, 4:53 a.m. OK GNU C++20 (64) TESTS 12 0 0
160162128 ys_zhd B June 11, 2022, 5:04 a.m. OK GNU C++20 (64) TESTS 12 0 0
160162912 Liang_zsy B June 11, 2022, 5:16 a.m. OK GNU C++20 (64) TESTS 12 0 0
160163615 MD.NROnik B June 11, 2022, 5:26 a.m. OK GNU C++20 (64) TESTS 12 0 0
160164180 hbnd_jaw1 B June 11, 2022, 5:35 a.m. OK GNU C++20 (64) TESTS 12 0 0
160164599 DrisHyam_420 B June 11, 2022, 5:41 a.m. OK GNU C++20 (64) TESTS 12 0 0
160164786 NAMAN_76 B June 11, 2022, 5:43 a.m. OK GNU C++20 (64) TESTS 12 0 0
160165694 harshyuvrajsingh2601 B June 11, 2022, 5:56 a.m. OK GNU C++20 (64) TESTS 12 0 0
160140534 Emruz_Hossain B June 10, 2022, 7:23 p.m. OK Go TESTS 12 15 307200
160148475 koqo B June 10, 2022, 9:53 p.m. OK Go TESTS 12 31 0
160158827 koqo B June 11, 2022, 4:04 a.m. OK Go TESTS 12 31 102400
160127806 srisairam B June 10, 2022, 6:10 p.m. OK Java 11 TESTS 12 171 0
160164526 nbhakar B June 11, 2022, 5:40 a.m. OK Java 11 TESTS 12 171 0
160160377 x21svage B June 11, 2022, 4:34 a.m. OK Java 11 TESTS 12 171 0
160157297 Juhaied_nabid B June 11, 2022, 3:28 a.m. OK Java 11 TESTS 12 171 0
160156837 aditya2024 B June 11, 2022, 3:16 a.m. OK Java 11 TESTS 12 171 0
160145831 profchi B June 10, 2022, 8:44 p.m. OK Java 11 TESTS 12 171 0
160143842 Ma-XD B June 10, 2022, 8:06 p.m. OK Java 11 TESTS 12 171 0
160143820 uma06 B June 10, 2022, 8:06 p.m. OK Java 11 TESTS 12 171 0
160162522 yogii_123 B June 11, 2022, 5:10 a.m. OK Java 11 TESTS 12 186 0
160153495 _milon_3.4 B June 11, 2022, 1:38 a.m. OK Java 11 TESTS 12 187 0
160158060 z_zhaojun B June 11, 2022, 3:46 a.m. OK Java 8 TESTS 12 93 0
160155503 shivam01_0 B June 11, 2022, 2:43 a.m. OK Java 8 TESTS 12 93 0
160139589 Virendra115 B June 10, 2022, 7:14 p.m. OK Java 8 TESTS 12 93 0
160159817 Ariful3671 B June 11, 2022, 4:24 a.m. OK Java 8 TESTS 12 93 0
160151026 faild-in-2021 B June 10, 2022, 11:40 p.m. OK Java 8 TESTS 12 108 0
160138455 Restricted B June 10, 2022, 7:05 p.m. OK Java 8 TESTS 12 108 0
160130178 var_hash B June 10, 2022, 6:18 p.m. OK Java 8 TESTS 12 108 0
160159129 tanishq044 B June 11, 2022, 4:10 a.m. OK Java 8 TESTS 12 108 0
160153968 priyaroy3370 B June 11, 2022, 1:56 a.m. OK Java 8 TESTS 12 109 0
160137232 dheerajchhatanidc B June 10, 2022, 6:59 p.m. OK Java 8 TESTS 12 109 0
160165176 BruteForcee B June 11, 2022, 5:49 a.m. OK Kotlin 1.4 TESTS 12 265 1638400
160148869 SlavaG B June 10, 2022, 10:05 p.m. OK Kotlin 1.6 TESTS 12 202 921600
160138748 mohamedbakr B June 10, 2022, 7:07 p.m. OK Mono C# TESTS 12 186 10547200
160154964 danthanhhuynhpham B June 11, 2022, 2:28 a.m. OK MS C++ 2017 TESTS 12 15 0
160149182 1_shivam B June 10, 2022, 10:16 p.m. OK MS C++ 2017 TESTS 12 15 0
160142454 sohail_377 B June 10, 2022, 7:45 p.m. OK MS C++ 2017 TESTS 12 15 0
160141837 Viktor36 B June 10, 2022, 7:38 p.m. OK MS C++ 2017 TESTS 12 15 0
160134044 EbisuSA B June 10, 2022, 6:30 p.m. OK MS C++ 2017 TESTS 12 15 0
160133830 Tamerhoumed B June 10, 2022, 6:29 p.m. OK MS C++ 2017 TESTS 12 15 0
160131070 WYW___ B June 10, 2022, 6:21 p.m. OK MS C++ 2017 TESTS 12 15 0
160126419 Bossusuprem B June 10, 2022, 6:05 p.m. OK MS C++ 2017 TESTS 12 15 0
160145310 Tor_250 B June 10, 2022, 8:33 p.m. OK MS C++ 2017 TESTS 12 30 0
160161525 XYShaoKang B June 11, 2022, 4:54 a.m. OK Node.js TESTS 12 93 204800
160131328 osato B June 10, 2022, 6:22 p.m. OK Node.js TESTS 12 124 1843200
160142255 krish_me B June 10, 2022, 7:43 p.m. OK Node.js TESTS 12 171 614400
160145112 yoralbayev B June 10, 2022, 8:30 p.m. OK PHP TESTS 12 31 0
160132117 mficco B June 10, 2022, 6:24 p.m. OK PyPy 3 TESTS 12 77 1433600
160147713 Mohamed_yousef2024 B June 10, 2022, 9:31 p.m. OK PyPy 3 TESTS 12 77 2048000
160126985 MegaCharizrdZ B June 10, 2022, 6:07 p.m. OK PyPy 3 TESTS 12 93 2150400
160141003 2021eeb1193 B June 10, 2022, 7:28 p.m. OK PyPy 3 TESTS 12 93 2355200
160140005 kboi B June 10, 2022, 7:17 p.m. OK PyPy 3 TESTS 12 93 4608000
160138027 Shaydiesin B June 10, 2022, 7:02 p.m. OK PyPy 3 TESTS 12 108 2048000
160159694 ambs_ B June 11, 2022, 4:21 a.m. OK PyPy 3 TESTS 12 109 1638400
160125947 abutyrev B June 10, 2022, 6:04 p.m. OK PyPy 3 TESTS 12 109 1843200
160161913 JohnX4321 B June 11, 2022, 5:01 a.m. OK PyPy 3 TESTS 12 109 2048000
160127758 Zhuchokk B June 10, 2022, 6:10 p.m. OK PyPy 3 TESTS 12 124 2457600
160128928 garbageCode.LOL B June 10, 2022, 6:14 p.m. OK PyPy 3-64 TESTS 12 62 512000
160138981 natale B June 10, 2022, 7:09 p.m. OK PyPy 3-64 TESTS 12 62 614400
160127850 1227haran B June 10, 2022, 6:10 p.m. OK PyPy 3-64 TESTS 12 62 614400
160157924 Turtleeee B June 11, 2022, 3:43 a.m. OK PyPy 3-64 TESTS 12 62 2048000
160157964 plevande B June 11, 2022, 3:44 a.m. OK PyPy 3-64 TESTS 12 62 2252800
160163628 abineth B June 11, 2022, 5:26 a.m. OK PyPy 3-64 TESTS 12 62 2355200
160155826 only_noob B June 11, 2022, 2:51 a.m. OK PyPy 3-64 TESTS 12 62 2457600
160147510 RANK1ZEN B June 10, 2022, 9:22 p.m. OK PyPy 3-64 TESTS 12 62 2867200
160138487 deyanuz B June 10, 2022, 7:05 p.m. OK PyPy 3-64 TESTS 12 77 614400
160145224 Martin53 B June 10, 2022, 8:32 p.m. OK PyPy 3-64 TESTS 12 77 2150400
160150294 JoeGibby B June 10, 2022, 11:04 p.m. OK Python 3 TESTS 12 31 0
160142867 Aditya_Sheoran B June 10, 2022, 7:51 p.m. OK Python 3 TESTS 12 31 0
160139938 riskr_21 B June 10, 2022, 7:17 p.m. OK Python 3 TESTS 12 31 0
160129990 OreoSensei B June 10, 2022, 6:18 p.m. OK Python 3 TESTS 12 31 0
160165900 saimu12 B June 11, 2022, 5:59 a.m. OK Python 3 TESTS 12 46 0
160165711 noob_coder_00 B June 11, 2022, 5:56 a.m. OK Python 3 TESTS 12 46 0
160150618 mihir111p B June 10, 2022, 11:19 p.m. OK Python 3 TESTS 12 46 0
160140177 Jokezor B June 10, 2022, 7:19 p.m. OK Python 3 TESTS 12 46 0
160138236 raushnn B June 10, 2022, 7:04 p.m. OK Python 3 TESTS 12 46 0
160137336 yuliya.sm7 B June 10, 2022, 6:59 p.m. OK Python 3 TESTS 12 46 0
160128951 isaiah_hex B June 10, 2022, 6:14 p.m. OK Rust 2021 TESTS 12 15 512000

remove filters

Back to search problems