Codeforces Round 1075 (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
2189 Codeforces Round 1075 (Div. 2) FINISHED False 7200 7226723 Jan. 23, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 6133 ) C2 XOR-convenience (Hard Version) PROGRAMMING bitmasks brute force constructive algorithms math

This is the hard version of the problem. The difference between the versions is that in this version, (1 \le i \le n-1). Note that a correct solution for the hard version is not necessarily a correct solution for the easy version. Given a positive integer (n). Find some permutation(^{\text{∗}}) (p) of length (n) such that for every (i) ((\style{color:red}{1 \le i \le n-1})) there exists (j) ((\style{color:red}{i \le j \le n})) such that (p_i = p_j \oplus i) (^{\text{†}}), or determine that it does not exist. (^{\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). (^{\text{†}})(\oplus) denotes the bitwise XOR operation . 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 only line of each test case contains one positive integer (n) ((3 \leq n \leq 2 \cdot 10^5)) — the length of the permutation. 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 a suitable permutation, output (n) integers (p_1,p_2,\ldots,p_n) — the permutation (p). Otherwise, output (-1). If multiple solutions exist, output any of them. In the first test case, the permutation (p = 2,1,3) fulfills the condition, as (p_2 = 1) and (p_3 \oplus 2 = 1). In the second test case, there is no suitable permutation.

Tutorials

Codeforces Round 1075 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
359504238 _Equinox C2 Jan. 24, 2026, 6 a.m. OK C# 13 TESTS 12 93 15667200
359496888 Tumi_Dusto C2 Jan. 24, 2026, 5:02 a.m. OK C++17 (GCC 7-32) TESTS 12 46 0
359481151 bruh05 C2 Jan. 23, 2026, 11:25 p.m. OK C++17 (GCC 7-32) TESTS 12 46 0
359480154 RockingMat C2 Jan. 23, 2026, 10:52 p.m. OK C++17 (GCC 7-32) TESTS 12 46 0
359474756 Gaurish16 C2 Jan. 23, 2026, 8:54 p.m. OK C++17 (GCC 7-32) TESTS 12 46 0
359474332 crankyvirgo C2 Jan. 23, 2026, 8:47 p.m. OK C++17 (GCC 7-32) TESTS 12 46 0
359454725 jonatas57 C2 Jan. 23, 2026, 5:37 p.m. OK C++17 (GCC 7-32) TESTS 12 46 0
359452450 Silas_Li C2 Jan. 23, 2026, 5:23 p.m. OK C++17 (GCC 7-32) TESTS 12 46 0
359450310 _Ramdas_ C2 Jan. 23, 2026, 5:11 p.m. OK C++17 (GCC 7-32) TESTS 12 46 0
359445232 000nobody000 C2 Jan. 23, 2026, 4:33 p.m. OK C++17 (GCC 7-32) TESTS 12 46 0
359443384 gong.teng C2 Jan. 23, 2026, 4:30 p.m. OK C++17 (GCC 7-32) TESTS 12 46 0
359500445 Syntaxerror31223 C2 Jan. 24, 2026, 5:33 a.m. OK C++20 (GCC 13-64) TESTS 12 31 0
359471255 ami1_code C2 Jan. 23, 2026, 8:05 p.m. OK C++20 (GCC 13-64) TESTS 12 31 0
359467915 turska C2 Jan. 23, 2026, 7:26 p.m. OK C++20 (GCC 13-64) TESTS 12 31 0
359449392 SherLocked25 C2 Jan. 23, 2026, 5:07 p.m. OK C++20 (GCC 13-64) TESTS 12 31 0
359445692 wildhonestfur C2 Jan. 23, 2026, 4:33 p.m. OK C++20 (GCC 13-64) TESTS 12 31 0
359490501 yuanmouren C2 Jan. 24, 2026, 3:29 a.m. OK C++20 (GCC 13-64) TESTS 12 31 102400
359473911 PipRa C2 Jan. 23, 2026, 8:41 p.m. OK C++20 (GCC 13-64) TESTS 12 31 307200
359486887 czkczk C2 Jan. 24, 2026, 2:20 a.m. OK C++20 (GCC 13-64) TESTS 12 31 7987200
359505252 Devesh77 C2 Jan. 24, 2026, 6:07 a.m. OK C++20 (GCC 13-64) TESTS 12 46 0
359504837 anotherworld C2 Jan. 24, 2026, 6:04 a.m. OK C++20 (GCC 13-64) TESTS 12 46 0
359504376 PrecipiceBlades C2 Jan. 24, 2026, 6:01 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 31 0
359503140 ranjit_thegreat C2 Jan. 24, 2026, 5:52 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 31 0
359498810 bitcrafter C2 Jan. 24, 2026, 5:19 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 31 0
359490984 AsobinoKankei C2 Jan. 24, 2026, 3:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 31 0
359488821 Ek1t1kE C2 Jan. 24, 2026, 2:57 a.m. OK C++23 (GCC 14-64, msys2) TESTS 12 31 0
359470075 krishna_saini C2 Jan. 23, 2026, 7:51 p.m. OK C++23 (GCC 14-64, msys2) TESTS 12 31 0
359469844 MrWizard_574 C2 Jan. 23, 2026, 7:49 p.m. OK C++23 (GCC 14-64, msys2) TESTS 12 31 0
359464813 suchethxplayer C2 Jan. 23, 2026, 6:55 p.m. OK C++23 (GCC 14-64, msys2) TESTS 12 31 0
359456396 Mishra_2006 C2 Jan. 23, 2026, 5:50 p.m. OK C++23 (GCC 14-64, msys2) TESTS 12 31 0
359455438 Tokisaki.kurumi C2 Jan. 23, 2026, 5:42 p.m. OK C++23 (GCC 14-64, msys2) TESTS 12 31 0
359457209 1435730 C2 Jan. 23, 2026, 5:55 p.m. OK GNU C11 TESTS 12 62 1638400
359443097 bablu_escobar C2 Jan. 23, 2026, 4:29 p.m. OK GNU C11 TESTS 12 890 1638400
359501824 yiren C2 Jan. 24, 2026, 5:43 a.m. OK Go TESTS 12 62 21299200
359500801 yiren_2 C2 Jan. 24, 2026, 5:35 a.m. OK Go TESTS 12 62 21299200
359443509 glebsamsonov C2 Jan. 23, 2026, 4:30 p.m. OK Go TESTS 12 109 3379200
359451402 buitS C2 Jan. 23, 2026, 5:17 p.m. OK Java 21 TESTS 12 218 512000
359470140 keshav_.agg C2 Jan. 23, 2026, 7:52 p.m. OK Java 21 TESTS 12 234 1331200
359450880 buitS C2 Jan. 23, 2026, 5:14 p.m. OK Java 21 TESTS 12 250 307200
359452818 vineetiwari C2 Jan. 23, 2026, 5:25 p.m. OK Java 21 TESTS 12 250 614400
359443399 xmjlove C2 Jan. 23, 2026, 4:30 p.m. OK Java 21 TESTS 12 250 819200
359499998 SujalJainn C2 Jan. 24, 2026, 5:29 a.m. OK Java 21 TESTS 12 250 1126400
359471277 Satyasarthi C2 Jan. 23, 2026, 8:05 p.m. OK Java 21 TESTS 12 265 1945600
359497600 balu2907 C2 Jan. 24, 2026, 5:08 a.m. OK Java 21 TESTS 12 265 15974400
359471551 ghost_248 C2 Jan. 23, 2026, 8:09 p.m. OK Java 21 TESTS 12 296 716800
359439951 LostDaemon C2 Jan. 23, 2026, 4:24 p.m. OK Java 21 TESTS 12 296 819200
359475725 public-static-void-main C2 Jan. 23, 2026, 9:12 p.m. OK Java 8 TESTS 12 250 16896000
359478799 divyanshvijay079 C2 Jan. 23, 2026, 10:14 p.m. OK Java 8 TESTS 12 296 0
359453096 kevin_0911 C2 Jan. 23, 2026, 5:27 p.m. OK Java 8 TESTS 12 296 0
359480545 tin.le2 C2 Jan. 23, 2026, 11:05 p.m. OK Kotlin 1.7 TESTS 12 359 30412800
359459680 SanjarAlgo C2 Jan. 23, 2026, 6:13 p.m. OK PascalABC.NET TESTS 12 546 1740800
359467339 Arvind215271 C2 Jan. 23, 2026, 7:21 p.m. OK PyPy 3 TESTS 12 406 9420800
359449437 999Wfan C2 Jan. 23, 2026, 5:07 p.m. OK PyPy 3 TESTS 12 453 11980800
359487939 kaushik.atla C2 Jan. 24, 2026, 2:42 a.m. OK PyPy 3-64 TESTS 12 78 7884800
359461338 abdullah_iw C2 Jan. 23, 2026, 6:25 p.m. OK PyPy 3-64 TESTS 12 93 9932800
359456752 mathiaswk C2 Jan. 23, 2026, 5:52 p.m. OK PyPy 3-64 TESTS 12 93 15769600
359499785 sharmaujjwal5706 C2 Jan. 24, 2026, 5:27 a.m. OK PyPy 3-64 TESTS 12 109 9113600
359464087 rishivk_144 C2 Jan. 23, 2026, 6:49 p.m. OK PyPy 3-64 TESTS 12 109 13516800
359458935 longjourney C2 Jan. 23, 2026, 6:08 p.m. OK PyPy 3-64 TESTS 12 109 15462400
359460082 know_pain C2 Jan. 23, 2026, 6:16 p.m. OK PyPy 3-64 TESTS 12 109 15872000
359446618 BlackSwanBase C2 Jan. 23, 2026, 4:34 p.m. OK PyPy 3-64 TESTS 12 109 16793600
359474967 isa773 C2 Jan. 23, 2026, 8:58 p.m. OK PyPy 3-64 TESTS 12 109 21504000
359453370 harvsftw C2 Jan. 23, 2026, 5:29 p.m. OK PyPy 3-64 TESTS 12 125 12800000
359439371 Jimanbanashi C2 Jan. 23, 2026, 4:23 p.m. OK Python 2 TESTS 12 218 15257600
359444334 rakshit__modi C2 Jan. 23, 2026, 4:31 p.m. OK Python 3 TESTS 12 156 16179200
359463119 AryansinghSonaye C2 Jan. 23, 2026, 6:40 p.m. OK Python 3 TESTS 12 265 8294400
359439656 khantnandeesh3205 C2 Jan. 23, 2026, 4:24 p.m. OK Python 3 TESTS 12 281 10035200
359465217 Jothiram_7 C2 Jan. 23, 2026, 6:59 p.m. OK Python 3 TESTS 12 281 11161600
359459342 ok12 C2 Jan. 23, 2026, 6:11 p.m. OK Python 3 TESTS 12 312 20275200
359501669 Aizon C2 Jan. 24, 2026, 5:42 a.m. OK Rust 2021 TESTS 12 62 2150400
359474045 charles0123 C2 Jan. 23, 2026, 8:43 p.m. OK Rust 2024 TESTS 12 46 0

remove filters

Back to search problems