Codeforces Round 1052 (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
2146 Codeforces Round 1052 (Div. 2) FINISHED False 8100 17940323 Sept. 21, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 10346 ) D1 Max Sum OR (Easy Version) PROGRAMMING bitmasks constructive algorithms divide and conquer greedy trees

This is the easy version of the problem. The difference between the versions is that in this version, (l=0), and (r<2\cdot 10^5). You can hack only if you solved all versions of this problem. You are given two integers (l) and (r) ((l\le r)). Let (n = r - l + 1). We will create two arrays (a) and (b), both consisting of (n) integers. Initially, both (a) and (b) are equal to (l, l+1, \ldots, r). You have to reorder the array (a) arbitrarily to maximize the following value: ()\sum_{i=1}^n \left (a_i\;|\;b_i \right ).() Here, (|) denotes the bitwise OR operation . You also need to construct a possible way to reorder the array (a). 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 two integers (l) and (r) ((0=l\leq r<2\cdot 10^5)) — the minimum and maximum elements in (a). Let (n = r - l + 1). It is guaranteed that the sum of (n) over all test cases does not exceed (2\cdot 10^5). For each test case, print a single integer in the first line of output — the maximum value of (\sum\limits_{i=1}^n \left (a_i\;|\;b_i \right )). Then, print (n) distinct integers (a_1, a_2, \ldots,a_n) in the second line — the array (a) after reordering. If there are multiple answers, you may print any of them. In the first test case, the reordered array (a) is (3,2,1,0). The value of the expression is ((3\;|\;0)+(2\;|\;1)+(1\;|\;2)+(0\;|\;3)=3+3+3+3=12). It can be proved that this is the maximum possible value of the expression. In the second test case, the reordered array (a) is (7,8,5,4,3,2,9,0,1,6). The value of the expression is (90). It can be proved that this is the maximum possible value of the expression.

Tutorials

Codeforces Round 1052 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
339834782 nanj0178 D1 Sept. 22, 2025, 6 a.m. OK C++17 (GCC 7-32) TESTS 11 62 0
339826543 nazeeftham007 D1 Sept. 22, 2025, 4:19 a.m. OK C++17 (GCC 7-32) TESTS 11 62 0
339825333 Rinker D1 Sept. 22, 2025, 4:03 a.m. OK C++17 (GCC 7-32) TESTS 11 62 0
339820638 Krish_0609 D1 Sept. 22, 2025, 2:54 a.m. OK C++17 (GCC 7-32) TESTS 11 62 0
339819993 shy_paper D1 Sept. 22, 2025, 2:46 a.m. OK C++17 (GCC 7-32) TESTS 11 62 0
339816054 hanlei35 D1 Sept. 22, 2025, 1:53 a.m. OK C++17 (GCC 7-32) TESTS 11 62 0
339808672 complexorigin D1 Sept. 21, 2025, 10:10 p.m. OK C++17 (GCC 7-32) TESTS 11 62 0
339801454 Akshay_Adak_289 D1 Sept. 21, 2025, 7:40 p.m. OK C++17 (GCC 7-32) TESTS 11 62 0
339797309 Teja-Smart D1 Sept. 21, 2025, 6:47 p.m. OK C++17 (GCC 7-32) TESTS 11 62 0
339795550 sifat_2017331054 D1 Sept. 21, 2025, 6:27 p.m. OK C++17 (GCC 7-32) TESTS 11 62 0
339835145 jocularferret D1 Sept. 22, 2025, 6:04 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
339833792 Pratyush_007 D1 Sept. 22, 2025, 5:49 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
339831142 Arman42 D1 Sept. 22, 2025, 5:22 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
339828952 LiZnB D1 Sept. 22, 2025, 4:55 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
339815625 sengardeep D1 Sept. 22, 2025, 1:46 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
339815154 aleC_aleC D1 Sept. 22, 2025, 1:38 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
339800028 Ormlis D1 Sept. 21, 2025, 7:20 p.m. OK C++20 (GCC 13-64) TESTS 11 46 0
339818182 joaovfp2002 D1 Sept. 22, 2025, 2:21 a.m. OK C++20 (GCC 13-64) TESTS 11 46 102400
339813729 lparra D1 Sept. 22, 2025, 1:05 a.m. OK C++20 (GCC 13-64) TESTS 11 46 4096000
339814152 MarioNathan D1 Sept. 22, 2025, 1:17 a.m. OK C++20 (GCC 13-64) TESTS 11 46 20070400
339828136 genshin-expert D1 Sept. 22, 2025, 4:43 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
339825862 prasoon107 D1 Sept. 22, 2025, 4:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
339823038 NWm D1 Sept. 22, 2025, 3:30 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
339822288 limx D1 Sept. 22, 2025, 3:18 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
339817472 molongdadi D1 Sept. 22, 2025, 2:11 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
339811870 Mindoongie D1 Sept. 22, 2025, 12:09 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
339827559 iliyian D1 Sept. 22, 2025, 4:34 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 102400
339777609 Vivek15Sahu D1 Sept. 21, 2025, 4:29 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 1638400
339830568 MaxDYF D1 Sept. 22, 2025, 5:17 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 61 0
339827859 Kita3 D1 Sept. 22, 2025, 4:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 61 0
339801768 ruban D1 Sept. 21, 2025, 7:44 p.m. OK FPC TESTS 11 280 38604800
339782419 1435730 D1 Sept. 21, 2025, 4:44 p.m. OK GNU C11 TESTS 11 92 1536000
339783673 pengin_2000 D1 Sept. 21, 2025, 4:47 p.m. OK GNU C11 TESTS 11 124 4915200
339780197 petsernik D1 Sept. 21, 2025, 4:37 p.m. OK Go TESTS 11 92 7168000
339771105 zap4eg D1 Sept. 21, 2025, 4:12 p.m. OK Go TESTS 11 312 3993600
339778944 AbhishekMaheshwari123 D1 Sept. 21, 2025, 4:33 p.m. OK Java 21 TESTS 11 249 512000
339806210 yuvrajye D1 Sept. 21, 2025, 9:03 p.m. OK Java 21 TESTS 11 249 614400
339810966 vatsal_04 D1 Sept. 21, 2025, 11:35 p.m. OK Java 21 TESTS 11 250 512000
339783988 priyank_4_sure D1 Sept. 21, 2025, 4:48 p.m. OK Java 21 TESTS 11 281 204800
339793292 Jon.Snow D1 Sept. 21, 2025, 6:03 p.m. OK Java 21 TESTS 11 281 2662400
339820421 punitpunde D1 Sept. 22, 2025, 2:51 a.m. OK Java 21 TESTS 11 312 409600
339807631 jacksparrow53536 D1 Sept. 21, 2025, 9:39 p.m. OK Java 21 TESTS 11 312 614400
339773605 DreamyDusk D1 Sept. 21, 2025, 4:19 p.m. OK Java 21 TESTS 11 312 921600
339783368 sulabhambule02 D1 Sept. 21, 2025, 4:46 p.m. OK Java 21 TESTS 11 312 1843200
339777897 punitpunde D1 Sept. 21, 2025, 4:30 p.m. OK Java 21 TESTS 11 327 512000
339770961 NeelmaniPandey09 D1 Sept. 21, 2025, 4:11 p.m. OK Java 8 TESTS 11 187 0
339770510 prime29 D1 Sept. 21, 2025, 4:10 p.m. OK Java 8 TESTS 11 342 15769600
339776668 testtest111ksjfrdvn D1 Sept. 21, 2025, 4:27 p.m. OK Java 8 TESTS 11 468 0
339781865 Parth63 D1 Sept. 21, 2025, 4:42 p.m. OK Java 8 TESTS 11 499 0
339780138 aaditya06pandey D1 Sept. 21, 2025, 4:37 p.m. OK Java 8 TESTS 11 499 0
339793524 saiashish9 D1 Sept. 21, 2025, 6:05 p.m. OK Java 8 TESTS 11 499 13721600
339779739 realSteel24 D1 Sept. 21, 2025, 4:35 p.m. OK Java 8 TESTS 11 500 0
339779271 AdityaPandey1368 D1 Sept. 21, 2025, 4:34 p.m. OK Java 8 TESTS 11 514 0
339779244 yashbansal99 D1 Sept. 21, 2025, 4:34 p.m. OK Java 8 TESTS 11 562 14643200
339796268 gn25 D1 Sept. 21, 2025, 6:35 p.m. OK Java 8 TESTS 11 593 15052800
339798718 A_23 D1 Sept. 21, 2025, 7:04 p.m. OK Kotlin 1.9 TESTS 11 249 12288000
339780562 practiceDaily1 D1 Sept. 21, 2025, 4:38 p.m. OK Node.js TESTS 11 468 85401600
339774872 mohitsharmakv05 D1 Sept. 21, 2025, 4:22 p.m. OK Node.js TESTS 11 515 91545600
339773058 Dangerous_Coder_69 D1 Sept. 21, 2025, 4:17 p.m. OK PyPy 3 TESTS 11 281 12390400
339783330 andrewliu10523 D1 Sept. 21, 2025, 4:46 p.m. OK PyPy 3 TESTS 11 327 12492800
339803163 Ayushman_123 D1 Sept. 21, 2025, 8:06 p.m. OK PyPy 3 TESTS 11 374 20582400
339779910 DSKroc D1 Sept. 21, 2025, 4:36 p.m. OK PyPy 3 TESTS 11 374 148992000
339811717 mahabub.510908 D1 Sept. 22, 2025, 12:03 a.m. OK PyPy 3 TESTS 11 531 13516800
339811445 _robosapiens_ D1 Sept. 21, 2025, 11:53 p.m. OK PyPy 3-64 TESTS 11 93 9523200
339810894 _robosapiens_ D1 Sept. 21, 2025, 11:32 p.m. OK PyPy 3-64 TESTS 11 93 10240000
339811207 _robosapiens_ D1 Sept. 21, 2025, 11:43 p.m. OK PyPy 3-64 TESTS 11 109 9523200
339810950 _robosapiens_ D1 Sept. 21, 2025, 11:35 p.m. OK PyPy 3-64 TESTS 11 109 9523200
339775129 YeasyLi D1 Sept. 21, 2025, 4:23 p.m. OK PyPy 3-64 TESTS 11 125 7680000
339811042 _robosapiens_ D1 Sept. 21, 2025, 11:37 p.m. OK PyPy 3-64 TESTS 11 140 9523200
339810942 _robosapiens_ D1 Sept. 21, 2025, 11:34 p.m. OK PyPy 3-64 TESTS 11 140 9523200
339810930 _robosapiens_ D1 Sept. 21, 2025, 11:34 p.m. OK PyPy 3-64 TESTS 11 140 9523200
339782166 fro_zexs D1 Sept. 21, 2025, 4:43 p.m. OK PyPy 3-64 TESTS 11 140 9523200
339808043 _robosapiens_ D1 Sept. 21, 2025, 9:51 p.m. OK PyPy 3-64 TESTS 11 140 10342400
339799870 Garv_12 D1 Sept. 21, 2025, 7:18 p.m. OK Python 3 TESTS 11 202 22118400
339776069 UjjwalTomar0808 D1 Sept. 21, 2025, 4:25 p.m. OK Python 3 TESTS 11 265 11468800
339780211 mudanvit.goyal D1 Sept. 21, 2025, 4:37 p.m. OK Python 3 TESTS 11 280 11366400
339784126 koushcodes D1 Sept. 21, 2025, 4:48 p.m. OK Python 3 TESTS 11 280 24166400
339783433 coderrg21 D1 Sept. 21, 2025, 4:46 p.m. OK Python 3 TESTS 11 281 12800000
339789354 kumarshrid06 D1 Sept. 21, 2025, 5:34 p.m. OK Python 3 TESTS 11 296 20377600
339775954 NijatHatamli02 D1 Sept. 21, 2025, 4:25 p.m. OK Python 3 TESTS 11 296 22528000
339781990 sachin_214 D1 Sept. 21, 2025, 4:42 p.m. OK Python 3 TESTS 11 311 11366400
339810947 penguinDoCode D1 Sept. 21, 2025, 11:34 p.m. OK Python 3 TESTS 11 327 11366400
339774370 nitish_biswas01 D1 Sept. 21, 2025, 4:21 p.m. OK Python 3 TESTS 11 359 13004800
339780860 EsotericPyramid D1 Sept. 21, 2025, 4:39 p.m. OK Rust 2021 TESTS 11 93 1331200
339775523 WASDetchan D1 Sept. 21, 2025, 4:24 p.m. OK Rust 2024 TESTS 11 92 102400

remove filters

Back to search problems