Codeforces Round 953 (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
1978 Codeforces Round 953 (Div. 2) FINISHED False 7200 18651263 June 16, 2024, 9:05 a.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 15487 ) C Manhattan Permutations PROGRAMMING constructive algorithms greedy implementation math

B'Let 's call the Manhattan value of a permutation ^{ dagger} p the value of the expression |p_1 - 1| + |p_2 - 2| + ldots + |p_n - n| . For example, for the permutation [1, 2, 3] , the Manhattan value is |1 - 1| + |2 - 2| + |3 - 3| = 0 , and for the permutation [3, 1, 2] , the Manhattan value is |3 - 1| + |1 - 2| + |2 - 3| = 2 + 1 + 1 = 4 . You are given integers n and k . Find a permutation p of length n such that its Manhattan value is equal to k , or determine that no such permutation exists. ^{ dagger} 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 consists of multiple test cases. The first line contains a single integer t ( 1 <= q t <= q 10^{4} ) -- the number of test cases. The description of the test cases follows. The only line of each test case contains two integers n and k ( 1 <= n <= 2 cdot 10^{5}, 0 <= k <= 10^{12} ) -- the length of the permutation and the required Manhattan value. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^{5} . For each test case, if there is no suitable permutation, output "No". Otherwise, in the first line, output "Yes", and in the second line, output n distinct integers p_1, p_2, ldots, p_n ( 1 <= p_i <= n ) -- a suitable permutation. If there are multiple solutions, output any of them. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as a positive answer). In the first test case, the permutation [3, 1, 2] is suitable, its Manhattan value is |3 - 1| + |1 - 2| + |2 - 3| = 2 + 1 + 1'...

Tutorials

130527

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
266119842 Grammar_hbw C June 17, 2024, 12:20 a.m. OK C++14 (GCC 6-32) TESTS 23 62 819200
266074936 MultiTrackKind C June 16, 2024, 2:32 p.m. OK C++14 (GCC 6-32) TESTS 20 62 819200
266083463 saadakbar10 C June 16, 2024, 3:38 p.m. OK C++14 (GCC 6-32) TESTS 20 62 4198400
266074663 Rishabhpndt C June 16, 2024, 2:30 p.m. OK C++14 (GCC 6-32) TESTS 20 62 4198400
266116719 int_R C June 16, 2024, 10:42 p.m. OK C++14 (GCC 6-32) TESTS 23 62 5017600
266137294 virraj C June 17, 2024, 5:34 a.m. OK C++14 (GCC 6-32) TESTS 23 77 0
266100987 i_m_scientist C June 16, 2024, 6:14 p.m. OK C++14 (GCC 6-32) TESTS 23 77 0
266086194 manyu19 C June 16, 2024, 4 p.m. OK C++14 (GCC 6-32) TESTS 21 77 0
266085907 Prayag_Kalriya_ C June 16, 2024, 3:58 p.m. OK C++14 (GCC 6-32) TESTS 21 77 0
266085671 jaikhatri6969 C June 16, 2024, 3:56 p.m. OK C++14 (GCC 6-32) TESTS 21 77 0
266077288 KASRA_BAHRAMI C June 16, 2024, 2:52 p.m. OK C++17 (GCC 7-32) TESTS 20 61 5836800
266136887 MigoQuQ C June 17, 2024, 5:29 a.m. OK C++17 (GCC 7-32) TESTS 23 62 0
266136146 Shawky_XR C June 17, 2024, 5:19 a.m. OK C++17 (GCC 7-32) TESTS 23 62 0
266133400 happydreamer C June 17, 2024, 4:41 a.m. OK C++17 (GCC 7-32) TESTS 23 62 0
266132374 adhikarysagnik04 C June 17, 2024, 4:25 a.m. OK C++17 (GCC 7-32) TESTS 23 62 0
266129762 vivek.kumar C June 17, 2024, 3:43 a.m. OK C++17 (GCC 7-32) TESTS 23 62 0
266129086 Objeban C June 17, 2024, 3:34 a.m. OK C++17 (GCC 7-32) TESTS 23 62 0
266127662 bourbon111 C June 17, 2024, 3:11 a.m. OK C++17 (GCC 7-32) TESTS 23 62 0
266124076 HHU_LING_YU C June 17, 2024, 2:06 a.m. OK C++17 (GCC 7-32) TESTS 23 62 0
266122556 FzArK C June 17, 2024, 1:33 a.m. OK C++17 (GCC 7-32) TESTS 23 62 0
266128464 StrangeBai C June 17, 2024, 3:24 a.m. OK C++20 (GCC 13-64) TESTS 23 46 0
266124924 NanJi115 C June 17, 2024, 2:24 a.m. OK C++20 (GCC 13-64) TESTS 23 46 0
266093858 almeidaraul C June 16, 2024, 5:06 p.m. OK C++20 (GCC 13-64) TESTS 23 46 0
266075728 GoymyGo C June 16, 2024, 2:39 p.m. OK C++20 (GCC 13-64) TESTS 20 46 0
266128345 K3br C June 17, 2024, 3:22 a.m. OK C++20 (GCC 13-64) TESTS 23 46 102400
266112732 tih-a C June 16, 2024, 9:02 p.m. OK C++20 (GCC 13-64) TESTS 23 46 102400
266113724 dartvolley C June 16, 2024, 9:23 p.m. OK C++20 (GCC 13-64) TESTS 23 46 1638400
266131746 pracLog C June 17, 2024, 4:16 a.m. OK C++20 (GCC 13-64) TESTS 23 46 3993600
266134936 Ankity_07 C June 17, 2024, 5:03 a.m. OK C++20 (GCC 13-64) TESTS 23 46 4096000
266127302 Jarvis_Z C June 17, 2024, 3:06 a.m. OK C++20 (GCC 13-64) TESTS 23 46 4096000
266072691 ruban C June 16, 2024, 2:13 p.m. OK Delphi TESTS 20 77 4403200
266108474 NenadDapic C June 16, 2024, 7:46 p.m. OK FPC TESTS 23 124 4710400
266107719 NenadDapic C June 16, 2024, 7:36 p.m. OK FPC TESTS 23 249 3891200
266107821 NenadDapic C June 16, 2024, 7:37 p.m. OK FPC TESTS 23 250 819200
266087321 rone_taiwan C June 16, 2024, 4:09 p.m. OK GNU C11 TESTS 22 77 819200
266121659 1435730 C June 17, 2024, 1:11 a.m. OK GNU C11 TESTS 23 77 921600
266087566 rone_taiwan C June 16, 2024, 4:11 p.m. OK GNU C11 TESTS 22 92 102400
266086919 rone_taiwan C June 16, 2024, 4:05 p.m. OK GNU C11 TESTS 22 780 819200
266105302 frocemetocode C June 16, 2024, 7:03 p.m. OK GNU C11 TESTS 23 796 921600
266087093 rone_taiwan C June 16, 2024, 4:07 p.m. OK GNU C11 TESTS 22 843 716800
266095906 coder0687 C June 16, 2024, 5:25 p.m. OK Java 21 TESTS 23 249 921600
266115587 dzhi C June 16, 2024, 10:08 p.m. OK Java 21 TESTS 23 265 1433600
266094889 priyaroy3370 C June 16, 2024, 5:15 p.m. OK Java 21 TESTS 23 280 3584000
266114254 powervic08 C June 16, 2024, 9:35 p.m. OK Java 21 TESTS 23 296 716800
266127606 Orange905 C June 17, 2024, 3:10 a.m. OK Java 21 TESTS 23 311 14643200
266088593 himneesh9 C June 16, 2024, 4:20 p.m. OK Java 21 TESTS 22 327 1638400
266065797 vinay_panwar C June 16, 2024, 1:23 p.m. OK Java 21 TESTS 20 343 921600
266113043 swatishivam23 C June 16, 2024, 9:09 p.m. OK Java 21 TESTS 23 374 1331200
266113784 lpychemistry C June 16, 2024, 9:24 p.m. OK Java 21 TESTS 23 421 16691200
266072805 Aatish_044 C June 16, 2024, 2:14 p.m. OK Java 21 TESTS 20 546 1126400
266116333 nis1234 C June 16, 2024, 10:29 p.m. OK Java 8 TESTS 23 171 0
266096795 NerfThis C June 16, 2024, 5:33 p.m. OK Java 8 TESTS 23 171 0
266136960 coderman2004 C June 17, 2024, 5:30 a.m. OK Java 8 TESTS 23 421 0
266108171 N0t_Kero C June 16, 2024, 7:42 p.m. OK Java 8 TESTS 23 436 0
266128930 bully_maguire C June 17, 2024, 3:31 a.m. OK Java 8 TESTS 23 452 0
266077465 Sumitsingh7 C June 16, 2024, 2:53 p.m. OK Java 8 TESTS 20 452 8192000
266074998 darkstars_stars C June 16, 2024, 2:33 p.m. OK Java 8 TESTS 20 452 8192000
266064755 om172 C June 16, 2024, 1:15 p.m. OK Java 8 TESTS 20 499 0
266069206 Jha_coder1942 C June 16, 2024, 1:53 p.m. OK Java 8 TESTS 20 499 5529600
266073292 YMSeah C June 16, 2024, 2:18 p.m. OK PyPy 3 TESTS 20 218 14950400
266113126 yashhwe C June 16, 2024, 9:10 p.m. OK PyPy 3 TESTS 23 296 19251200
266127034 nealzane C June 17, 2024, 3:01 a.m. OK PyPy 3 TESTS 23 343 14643200
266112647 yashhwe C June 16, 2024, 9 p.m. OK PyPy 3 TESTS 23 358 17920000
266130046 cyan17 C June 17, 2024, 3:48 a.m. OK PyPy 3 TESTS 23 389 11673600
266113072 yashhwe C June 16, 2024, 9:09 p.m. OK PyPy 3 TESTS 23 389 17920000
266074607 YMSeah C June 16, 2024, 2:29 p.m. OK PyPy 3-64 TESTS 20 124 16691200
266114330 PhenomSG C June 16, 2024, 9:37 p.m. OK PyPy 3-64 TESTS 23 124 22528000
266092070 aayush249 C June 16, 2024, 4:50 p.m. OK PyPy 3-64 TESTS 23 139 7270400
266121720 yefei162 C June 17, 2024, 1:13 a.m. OK PyPy 3-64 TESTS 23 140 6758400
266107036 gardengnome C June 16, 2024, 7:26 p.m. OK PyPy 3-64 TESTS 23 140 10035200
266118571 Nullz C June 16, 2024, 11:39 p.m. OK PyPy 3-64 TESTS 23 140 13414400
266064724 scyyyyyyyyyy C June 16, 2024, 1:15 p.m. OK PyPy 3-64 TESTS 20 155 14028800
266124528 Newbie_ C June 17, 2024, 2:16 a.m. OK PyPy 3-64 TESTS 23 155 15974400
266073351 udayan8 C June 16, 2024, 2:18 p.m. OK PyPy 3-64 TESTS 20 155 16179200
266075996 ankan2526 C June 16, 2024, 2:41 p.m. OK PyPy 3-64 TESTS 20 155 143974400
266076577 shangzhexin C June 16, 2024, 2:46 p.m. OK Python 3 TESTS 20 202 32460800
266131516 eugalt C June 17, 2024, 4:12 a.m. OK Python 3 TESTS 23 281 10956800
266097609 KGC_444 C June 16, 2024, 5:41 p.m. OK Python 3 TESTS 23 296 9113600
266063932 prathamsibal81 C June 16, 2024, 1:09 p.m. OK Python 3 TESTS 20 296 10854400
266131646 eugalt C June 17, 2024, 4:14 a.m. OK Python 3 TESTS 23 296 10956800
266131244 eugalt C June 17, 2024, 4:07 a.m. OK Python 3 TESTS 23 296 10956800
266078813 Toy_mouse C June 16, 2024, 3:03 p.m. OK Python 3 TESTS 20 311 10752000
266064290 Devarshi_19 C June 16, 2024, 1:12 p.m. OK Python 3 TESTS 20 311 11468800
266065493 azamovazamkhon C June 16, 2024, 1:21 p.m. OK Python 3 TESTS 20 311 12492800
266098833 deepak19 C June 16, 2024, 5:53 p.m. OK Python 3 TESTS 23 327 11468800
266117944 0x81 C June 16, 2024, 11:21 p.m. OK Ruby 3 TESTS 23 359 7270400
266104048 kingcabrams C June 16, 2024, 6:48 p.m. OK Rust 2021 TESTS 23 77 0
266117157 M1ngXu C June 16, 2024, 10:56 p.m. OK Rust 2021 TESTS 23 78 8601600

remove filters

Back to search problems