Codeforces Round 771 (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
1638 Codeforces Round 771 (Div. 2) FINISHED False 7200 92417063 Feb. 14, 2022, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 21617 ) A Reverse PROGRAMMING greedy math

B'You are given a permutation p_1, p_2, ldots, p_n of length n . You have to choose two integers l,r ( 1 <= l <= r <= n ) and reverse the subsegment [l,r] of the permutation. The permutation will become p_1,p_2, ... , p_{l-1},p_r,p_{r-1}, ... , p_l,p_{r+1},p_{r+2}, ... ,p_n . Find the lexicographically smallest permutation that can be obtained by performing exactly one reverse operation on the initial permutation. Note that for two distinct permutations of equal length a and b , a is lexicographically smaller than b if at the first position they differ, a has the smaller element. A permutation 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 a single integer t ( 1 <= t <= 500 ) -- the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 500 ) -- the length of the permutation. The second line of each test case contains n integers p_1, p_2, ... , p_n ( 1 <= p_i <= n ) -- the elements of the permutation. For each test case print the lexicographically smallest permutation you can obtain. In the first test case, the permutation has length 1 , so the only possible segment is [1,1] . The resulting permutation is [1] . In the second test case, we can obtain the identity permutation by reversing the segment [1,2] . The resulting permutation is [1,2,3] . In the third test case, the best possible segment is [2,3] . The resulting permutation is [1,2,4,3] . In the fourth test case, there is no lexicographically smaller p'...

Tutorials

Codeforces Round #771 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
146467817 hhj16166 A Feb. 15, 2022, 3:20 a.m. OK GNU C11 TESTS 14 951 0
146468551 haran7 A Feb. 15, 2022, 3:32 a.m. OK GNU C11 TESTS 14 951 0
146423134 anmol_kp0612 A Feb. 14, 2022, 4:22 p.m. OK GNU C11 TESTS 14 966 0
146462015 FZUXMAN A Feb. 15, 2022, 1:14 a.m. OK GNU C11 TESTS 14 966 0
146422971 Nakul_NRA A Feb. 14, 2022, 4:22 p.m. OK GNU C11 TESTS 14 966 0
146474386 keutoi A Feb. 15, 2022, 4:57 a.m. OK GNU C11 TESTS 14 967 0
146450717 rainboy A Feb. 14, 2022, 8:03 p.m. OK GNU C11 TESTS 14 967 0
146457268 matlab A Feb. 14, 2022, 10:14 p.m. OK GNU C11 TESTS 14 967 0
146446530 predawn A Feb. 14, 2022, 7:18 p.m. OK GNU C11 TESTS 14 967 1024000
146460995 Murli_33 A Feb. 15, 2022, 12:41 a.m. OK GNU C11 TESTS 14 967 1638400
146419661 supratims_2002 A Feb. 14, 2022, 4:13 p.m. OK GNU C++14 TESTS 14 46 204800
146476666 Tanvirrafi A Feb. 15, 2022, 5:27 a.m. OK GNU C++14 TESTS 14 46 204800
146468862 20203246 A Feb. 15, 2022, 3:37 a.m. OK GNU C++14 TESTS 14 46 204800
146456149 Shinchan12 A Feb. 14, 2022, 9:42 p.m. OK GNU C++14 TESTS 14 46 204800
146465290 little_ge A Feb. 15, 2022, 2:31 a.m. OK GNU C++14 TESTS 14 46 3993600
146477926 NooB_Holmes A Feb. 15, 2022, 5:42 a.m. OK GNU C++14 TESTS 14 46 42700800
146474891 SPEEDXY A Feb. 15, 2022, 5:04 a.m. OK GNU C++14 TESTS 14 61 0
146472253 vansh_69420 A Feb. 15, 2022, 4:27 a.m. OK GNU C++14 TESTS 14 61 0
146471893 vansh_69420 A Feb. 15, 2022, 4:22 a.m. OK GNU C++14 TESTS 14 61 0
146462818 202103023413 A Feb. 15, 2022, 1:35 a.m. OK GNU C++14 TESTS 14 61 0
146462688 AbdullahMostafa A Feb. 15, 2022, 1:32 a.m. OK GNU C++17 TESTS 14 46 0
146473153 yashkhamkar1100 A Feb. 15, 2022, 4:40 a.m. OK GNU C++17 TESTS 14 46 102400
146478311 DiptoArchyes07 A Feb. 15, 2022, 5:46 a.m. OK GNU C++17 TESTS 14 46 102400
146467172 Thetemka228 A Feb. 15, 2022, 3:08 a.m. OK GNU C++17 TESTS 14 46 102400
146446332 aadityarathi7 A Feb. 14, 2022, 7:16 p.m. OK GNU C++17 TESTS 14 46 102400
146467739 nevergiveup0001 A Feb. 15, 2022, 3:19 a.m. OK GNU C++17 TESTS 14 46 204800
146466044 Nawaz19 A Feb. 15, 2022, 2:46 a.m. OK GNU C++17 TESTS 14 46 204800
146475716 Asif_Iqubal_18 A Feb. 15, 2022, 5:15 a.m. OK GNU C++17 TESTS 14 46 204800
146471658 changinmong10 A Feb. 15, 2022, 4:19 a.m. OK GNU C++17 TESTS 14 46 204800
146470877 aryanbhat_10 A Feb. 15, 2022, 4:07 a.m. OK GNU C++17 TESTS 14 46 204800
146451447 lightseba A Feb. 14, 2022, 8:14 p.m. OK GNU C++17 (64) TESTS 14 30 0
146453495 Prof.Shikari A Feb. 14, 2022, 8:48 p.m. OK GNU C++17 (64) TESTS 14 30 102400
146463691 linxd A Feb. 15, 2022, 1:58 a.m. OK GNU C++17 (64) TESTS 14 30 4812800
146474690 LAB A Feb. 15, 2022, 5:01 a.m. OK GNU C++17 (64) TESTS 14 31 0
146463650 _despair_ A Feb. 15, 2022, 1:57 a.m. OK GNU C++17 (64) TESTS 14 31 0
146459653 Mohammad_Ayman A Feb. 14, 2022, 11:53 p.m. OK GNU C++17 (64) TESTS 14 31 0
146459515 PurpleCrayon A Feb. 14, 2022, 11:48 p.m. OK GNU C++17 (64) TESTS 14 31 0
146448995 mahbubhasanmht A Feb. 14, 2022, 7:41 p.m. OK GNU C++17 (64) TESTS 14 31 0
146478916 Tanzim_bn A Feb. 15, 2022, 5:54 a.m. OK GNU C++17 (64) TESTS 14 31 0
146477548 InFaNg A Feb. 15, 2022, 5:38 a.m. OK GNU C++17 (64) TESTS 14 31 0
146467628 Githm A Feb. 15, 2022, 3:16 a.m. OK GNU C++20 (64) TESTS 14 15 0
146471348 nguyenckhanh71 A Feb. 15, 2022, 4:14 a.m. OK GNU C++20 (64) TESTS 14 15 0
146448235 yvchaurasia11 A Feb. 14, 2022, 7:33 p.m. OK GNU C++20 (64) TESTS 14 30 0
146445126 danish_10 A Feb. 14, 2022, 7:10 p.m. OK GNU C++20 (64) TESTS 14 30 102400
146471190 Bit_8 A Feb. 15, 2022, 4:12 a.m. OK GNU C++20 (64) TESTS 14 30 102400
146467630 Big_Big_moon A Feb. 15, 2022, 3:16 a.m. OK GNU C++20 (64) TESTS 14 30 28057600
146479151 Aish0749 A Feb. 15, 2022, 5:57 a.m. OK GNU C++20 (64) TESTS 14 31 0
146479566 anas_ahmad_khan A Feb. 15, 2022, 6:01 a.m. OK GNU C++20 (64) TESTS 14 31 0
146478904 BenSim A Feb. 15, 2022, 5:54 a.m. OK GNU C++20 (64) TESTS 14 31 0
146477619 teraqqq A Feb. 15, 2022, 5:39 a.m. OK GNU C++20 (64) TESTS 14 31 0
146461577 meooow A Feb. 15, 2022, 1:01 a.m. OK Haskell TESTS 14 93 0
146462735 Nick A Feb. 15, 2022, 1:33 a.m. OK Java 11 TESTS 14 202 0
146459159 robinz62 A Feb. 14, 2022, 11:33 p.m. OK Java 11 TESTS 14 202 0
146453851 cheenipapa A Feb. 14, 2022, 8:55 p.m. OK Java 11 TESTS 14 202 0
146456451 SAMAD_ A Feb. 14, 2022, 9:50 p.m. OK Java 11 TESTS 14 217 0
146445619 SJacob A Feb. 14, 2022, 7:12 p.m. OK Java 11 TESTS 14 218 0
146469526 SaberXpro A Feb. 15, 2022, 3:47 a.m. OK Java 11 TESTS 14 218 0
146449691 KarMa_ A Feb. 14, 2022, 7:50 p.m. OK Java 11 TESTS 14 218 0
146445781 ujjwalll A Feb. 14, 2022, 7:13 p.m. OK Java 11 TESTS 14 218 0
146419273 Isha010 A Feb. 14, 2022, 4:11 p.m. OK Java 11 TESTS 14 218 0
146476856 CrinklyGolem A Feb. 15, 2022, 5:30 a.m. OK Java 11 TESTS 14 233 0
146457439 liheman A Feb. 14, 2022, 10:19 p.m. OK Java 8 TESTS 14 124 0
146452819 sachin32 A Feb. 14, 2022, 8:36 p.m. OK Java 8 TESTS 14 124 0
146448536 Mohamed_A7med A Feb. 14, 2022, 7:36 p.m. OK Java 8 TESTS 14 124 0
146476302 P_Key26dec A Feb. 15, 2022, 5:22 a.m. OK Java 8 TESTS 14 139 17817600
146449630 _Eyepatch A Feb. 14, 2022, 7:49 p.m. OK Java 8 TESTS 14 155 0
146425086 madhav2800 A Feb. 14, 2022, 4:27 p.m. OK Java 8 TESTS 14 155 0
146465581 shaurya024 A Feb. 15, 2022, 2:37 a.m. OK Java 8 TESTS 14 327 0
146425535 shivam01_0 A Feb. 14, 2022, 4:28 p.m. OK Java 8 TESTS 14 343 0
146479021 oneafter A Feb. 15, 2022, 5:55 a.m. OK Java 8 TESTS 14 841 0
146476402 Lelouch_12 A Feb. 15, 2022, 5:24 a.m. OK Java 8 TESTS 14 841 0
146461626 ryanberg A Feb. 15, 2022, 1:03 a.m. OK Kotlin 1.5 TESTS 14 280 819200
146474735 02Yuchen A Feb. 15, 2022, 5:02 a.m. OK MS C++ 2017 TESTS 14 264 0
146475729 02Yuchen A Feb. 15, 2022, 5:15 a.m. OK MS C++ 2017 TESTS 14 265 0
146450209 itmosha A Feb. 14, 2022, 7:56 p.m. OK MS C++ 2017 TESTS 14 265 0
146453127 Kanata369 A Feb. 14, 2022, 8:42 p.m. OK MS C++ 2017 TESTS 14 280 0
146462956 qwqa A Feb. 15, 2022, 1:39 a.m. OK MS C++ 2017 TESTS 14 296 0
146423229 MRX7 A Feb. 14, 2022, 4:22 p.m. OK MS C++ 2017 TESTS 14 312 0
146453626 ddcovery A Feb. 14, 2022, 8:51 p.m. OK Node.js TESTS 14 93 6553600
146454400 _con A Feb. 14, 2022, 9:05 p.m. OK Node.js TESTS 14 108 6041600
146466857 mtester A Feb. 15, 2022, 3:02 a.m. OK Node.js TESTS 14 935 26112000
146466895 mtester A Feb. 15, 2022, 3:03 a.m. OK Node.js TESTS 14 982 26112000
146445355 1_2_3_4_5_9 A Feb. 14, 2022, 7:11 p.m. OK PyPy 2 TESTS 14 109 5222400
146477061 feelme A Feb. 15, 2022, 5:32 a.m. OK PyPy 3 TESTS 14 140 6758400
146445127 NecroSean38 A Feb. 14, 2022, 7:10 p.m. OK PyPy 3 TESTS 14 155 5017600
146455555 hritik3878 A Feb. 14, 2022, 9:29 p.m. OK PyPy 3 TESTS 14 155 7168000
146458502 crapcode A Feb. 14, 2022, 10:54 p.m. OK PyPy 3 TESTS 14 295 10240000
146449405 Abdusharif A Feb. 14, 2022, 7:46 p.m. OK PyPy 3 TESTS 14 311 9216000
146448682 definisto A Feb. 14, 2022, 7:38 p.m. OK PyPy 3 TESTS 14 311 9318400
146471873 pks667553 A Feb. 15, 2022, 4:22 a.m. OK PyPy 3 TESTS 14 311 9523200
146459786 jamzz8 A Feb. 14, 2022, 11:59 p.m. OK PyPy 3 TESTS 14 311 9523200
146445859 ldyllic A Feb. 14, 2022, 7:13 p.m. OK PyPy 3 TESTS 14 327 9523200
146461076 rbamhore20 A Feb. 15, 2022, 12:44 a.m. OK PyPy 3 TESTS 14 342 9523200
146445302 manish.17 A Feb. 14, 2022, 7:11 p.m. OK PyPy 3-64 TESTS 14 124 9011200
146453546 IkshitG A Feb. 14, 2022, 8:49 p.m. OK PyPy 3-64 TESTS 14 218 11366400
146453379 itsyogeshniranjan A Feb. 14, 2022, 8:46 p.m. OK PyPy 3-64 TESTS 14 264 10547200
146463313 rutz12 A Feb. 15, 2022, 1:48 a.m. OK PyPy 3-64 TESTS 14 265 10035200
146459509 fan_of_tourist A Feb. 14, 2022, 11:48 p.m. OK PyPy 3-64 TESTS 14 280 10752000
146445679 ldyllic A Feb. 14, 2022, 7:12 p.m. OK PyPy 3-64 TESTS 14 295 10752000
146452266 freakbuoyancy A Feb. 14, 2022, 8:27 p.m. OK PyPy 3-64 TESTS 14 296 10649600
146455921 MrVroom999 A Feb. 14, 2022, 9:37 p.m. OK PyPy 3-64 TESTS 14 311 10137600
146463301 rutz12 A Feb. 15, 2022, 1:48 a.m. OK PyPy 3-64 TESTS 14 311 10649600
146457073 NTPhuongThao A Feb. 14, 2022, 10:07 p.m. OK PyPy 3-64 TESTS 14 311 10956800
146456901 OLOGY A Feb. 14, 2022, 10:03 p.m. OK Python 2 TESTS 14 171 2048000
146457833 OLOGY A Feb. 14, 2022, 10:30 p.m. OK Python 2 TESTS 14 187 819200
146445621 OLOGY A Feb. 14, 2022, 7:12 p.m. OK Python 2 TESTS 14 202 2048000
146424294 FelixS A Feb. 14, 2022, 4:25 p.m. OK Python 3 TESTS 14 155 921600
146471008 alextretyak A Feb. 15, 2022, 4:09 a.m. OK Python 3 TESTS 14 186 1024000
146419407 sandeeptosol A Feb. 14, 2022, 4:12 p.m. OK Python 3 TESTS 14 202 819200
146462383 CoolManGame A Feb. 15, 2022, 1:24 a.m. OK Python 3 TESTS 14 249 1433600
146475224 saimanoj_22 A Feb. 15, 2022, 5:08 a.m. OK Python 3 TESTS 14 327 1024000
146450632 eugalt A Feb. 14, 2022, 8:02 p.m. OK Python 3 TESTS 14 327 1843200
146468484 xuem7294 A Feb. 15, 2022, 3:31 a.m. OK Python 3 TESTS 14 342 1024000
146446342 gck_16 A Feb. 14, 2022, 7:16 p.m. OK Python 3 TESTS 14 342 1126400
146421162 Ignatius6103 A Feb. 14, 2022, 4:17 p.m. OK Python 3 TESTS 14 343 614400
146452274 eugalt A Feb. 14, 2022, 8:27 p.m. OK Python 3 TESTS 14 343 1638400
146447764 qwerty787788 A Feb. 14, 2022, 7:29 p.m. OK Rust 2021 TESTS 14 46 0

remove filters

Back to search problems