Codeforces Round 1022 (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
2108 Codeforces Round 1022 (Div. 2) FINISHED False 7200 30295523 May 1, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 14479 ) B SUMdamental Decomposition PROGRAMMING bitmasks constructive algorithms greedy implementation math

On a recent birthday, your best friend Maurice gave you a pair of numbers (n) and (x), and asked you to construct an array of positive numbers (a) of length (n) such that (a_1 \oplus a_2 \oplus \cdots \oplus a_n = x) (^{\text{∗}}). This task seemed too simple to you, and therefore you decided to give Maurice a return gift by constructing an array among all such arrays that has the smallest sum of its elements. You immediately thought of a suitable array; however, since writing it down turned out to be too time-consuming, Maurice will have to settle for just the sum of its elements. (^{\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. Each test case consists of a single line containing a pair of numbers (n) and (x) ((1 \le n \le 10^9, \; 0 \le x \le 10^9)) — the numbers given to you by Maurice. For each test case, output your gift to Maurice — the sum of the elements of the array that satisfies all the described properties. If a suitable array does not exist, output (-1). In the first test case, one of the suitable arrays is (2, 3). It can be shown that it is impossible to achieve a smaller sum of array elements. In the second case, one of the suitable arrays is (1, 3, 4). It can also be shown that this is the optimal amount.

Tutorials

Codeforces Round 1022 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
318056088 Equinox_Ya B May 2, 2025, 2:58 a.m. OK C# 10 TESTS 11 171 9932800
318067588 utkarsh952 B May 2, 2025, 5:53 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
318063234 Anand_Bharti B May 2, 2025, 4:59 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
318060484 Pacific_Hues B May 2, 2025, 4:13 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
318060229 ProTeam15 B May 2, 2025, 4:08 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
318058742 WACEee B May 2, 2025, 3:43 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
318058124 raghavs1304 B May 2, 2025, 3:32 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
318057646 Shenyurou B May 2, 2025, 3:24 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
318056535 jxiaoming1 B May 2, 2025, 3:07 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
318054473 Ayanami_z41 B May 2, 2025, 2:28 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
318054112 me_none B May 2, 2025, 2:21 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
318068559 Hmzaawy B May 2, 2025, 6:03 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
318067416 pp031608 B May 2, 2025, 5:51 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
318066762 fardinfaruqi B May 2, 2025, 5:44 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
318066607 Hmzaawy B May 2, 2025, 5:42 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
318066448 kishorrik B May 2, 2025, 5:40 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
318065304 DawnFall119 B May 2, 2025, 5:26 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
318063810 ShAdowLiAr B May 2, 2025, 5:07 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
318063014 Ghtme B May 2, 2025, 4:55 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
318061572 timerl B May 2, 2025, 4:32 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
318061001 Jayy__07 B May 2, 2025, 4:22 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
318068561 B4NK0R1L053 B May 2, 2025, 6:03 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
318068340 Tenryon B May 2, 2025, 6:01 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
318067610 TO_zero B May 2, 2025, 5:53 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
318067477 Luffy_18 B May 2, 2025, 5:52 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
318067213 HTyin B May 2, 2025, 5:49 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
318066804 King_Anant_Ranjan B May 2, 2025, 5:44 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
318066747 yolo.lyc B May 2, 2025, 5:44 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
318065869 pro_coder2.0 B May 2, 2025, 5:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
318065600 goromPani B May 2, 2025, 5:30 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
318065096 _Raunak_ B May 2, 2025, 5:23 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
318032339 aishanbhagat B May 1, 2025, 6:54 p.m. OK GNU C11 TESTS 11 140 102400
318047268 yashjaiswal2509 B May 1, 2025, 11:08 p.m. OK Java 21 TESTS 11 218 921600
318038355 jerdno B May 1, 2025, 8:10 p.m. OK Java 21 TESTS 11 233 1024000
318017855 sulabhambule B May 1, 2025, 5:02 p.m. OK Java 21 TESTS 11 249 512000
318061181 sulabhambule B May 2, 2025, 4:25 a.m. OK Java 21 TESTS 11 249 716800
318032549 the_bigShort B May 1, 2025, 6:56 p.m. OK Java 21 TESTS 11 249 716800
318031666 akshatsaxena552004.ss B May 1, 2025, 6:48 p.m. OK Java 21 TESTS 11 249 716800
318013677 dhanya_17 B May 1, 2025, 4:32 p.m. OK Java 21 TESTS 11 249 716800
318012628 Power_Rangers_ B May 1, 2025, 4:30 p.m. OK Java 21 TESTS 11 249 819200
318063247 bomakhamchha B May 2, 2025, 4:59 a.m. OK Java 21 TESTS 11 249 921600
318067045 nhant B May 2, 2025, 5:47 a.m. OK Java 21 TESTS 11 249 1331200
318050631 baixuejava B May 2, 2025, 1 a.m. OK Java 8 TESTS 11 140 0
318025690 Pranav_45 B May 1, 2025, 5:53 p.m. OK Java 8 TESTS 11 140 0
318058978 kartik__sethi B May 2, 2025, 3:47 a.m. OK Java 8 TESTS 11 155 0
318010854 Chiffin B May 1, 2025, 4:26 p.m. OK Java 8 TESTS 11 171 0
318010005 Kuuuuuuuuu B May 1, 2025, 4:24 p.m. OK Java 8 TESTS 11 171 0
318007980 sachinbisht2961 B May 1, 2025, 4:19 p.m. OK Java 8 TESTS 11 171 0
318068485 Dduo B May 2, 2025, 6:02 a.m. OK Java 8 TESTS 11 187 0
318060009 adarsh400 B May 2, 2025, 4:05 a.m. OK Java 8 TESTS 11 233 0
318054136 kunal021 B May 2, 2025, 2:21 a.m. OK Java 8 TESTS 11 233 0
318020490 not_mohith B May 1, 2025, 5:17 p.m. OK Java 8 TESTS 11 233 0
318039359 jagbarrameda B May 1, 2025, 8:25 p.m. OK Kotlin 1.9 TESTS 11 203 409600
318012411 The_Bharadwaj B May 1, 2025, 4:29 p.m. OK Node.js TESTS 11 702 11878400
318008011 pipylon B May 1, 2025, 4:19 p.m. OK PyPy 3 TESTS 11 249 7475200
318066923 Pabloo-04 B May 2, 2025, 5:46 a.m. OK PyPy 3 TESTS 11 249 7577600
318007326 Code.Virtuoso B May 1, 2025, 4:18 p.m. OK PyPy 3 TESTS 11 281 9728000
318019083 Srivissy B May 1, 2025, 5:09 p.m. OK PyPy 3 TESTS 11 296 7577600
318032391 Akiii_2023 B May 1, 2025, 6:54 p.m. OK PyPy 3 TESTS 11 312 8396800
318014461 Aarya_01 B May 1, 2025, 4:33 p.m. OK PyPy 3 TESTS 11 358 8396800
318024545 Aarya_01 B May 1, 2025, 5:44 p.m. OK PyPy 3 TESTS 11 374 8396800
318051020 gardengnome B May 2, 2025, 1:09 a.m. OK PyPy 3-64 TESTS 11 93 3686400
318052225 ege_erdil B May 2, 2025, 1:41 a.m. OK PyPy 3-64 TESTS 11 124 5017600
318031711 Canyonzzzzz B May 1, 2025, 6:48 p.m. OK PyPy 3-64 TESTS 11 124 5529600
318043781 amongsus B May 1, 2025, 9:41 p.m. OK PyPy 3-64 TESTS 11 125 5939200
318058403 hxu10 B May 2, 2025, 3:38 a.m. OK PyPy 3-64 TESTS 11 139 4710400
318029124 MagicDrago B May 1, 2025, 6:22 p.m. OK PyPy 3-64 TESTS 11 140 3993600
318033770 Canyonzzzzz B May 1, 2025, 7:10 p.m. OK PyPy 3-64 TESTS 11 140 5324800
318037915 MaxPozniak B May 1, 2025, 8:03 p.m. OK PyPy 3-64 TESTS 11 140 6860800
318011095 ossau B May 1, 2025, 4:27 p.m. OK PyPy 3-64 TESTS 11 155 3788800
318033460 venkata_narendra B May 1, 2025, 7:06 p.m. OK PyPy 3-64 TESTS 11 155 4300800
318057311 ruhittanvir14 B May 2, 2025, 3:19 a.m. OK Python 3 TESTS 11 92 512000
318033687 DevarshPatel B May 1, 2025, 7:09 p.m. OK Python 3 TESTS 11 109 307200
318012379 Yunbvfrty B May 1, 2025, 4:29 p.m. OK Python 3 TESTS 11 140 204800
318011028 fjueic B May 1, 2025, 4:26 p.m. OK Python 3 TESTS 11 140 307200
318051270 coder.sy B May 2, 2025, 1:16 a.m. OK Python 3 TESTS 11 171 204800
318026808 lucascostaval B May 1, 2025, 6:02 p.m. OK Python 3 TESTS 11 171 204800
318013675 Deathstroke19891 B May 1, 2025, 4:32 p.m. OK Python 3 TESTS 11 171 307200
318007072 Retr_1 B May 1, 2025, 4:17 p.m. OK Python 3 TESTS 11 187 204800
318011776 kvayne B May 1, 2025, 4:28 p.m. OK Python 3 TESTS 11 327 819200
318041495 programming_to_learn B May 1, 2025, 8:58 p.m. OK Python 3 TESTS 11 781 512000
318054491 silicalet B May 2, 2025, 2:28 a.m. OK Rust 2021 TESTS 11 77 102400
318015635 bad_imagination B May 1, 2025, 4:34 p.m. OK Rust 2021 TESTS 11 77 102400

remove filters

Back to search problems