Codeforces Round 1064 (Div. 1)

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
2165 Codeforces Round 1064 (Div. 1) FINISHED False 7200 13101923 Nov. 16, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 3470 ) C Binary Wine PROGRAMMING bitmasks greedy

You are given (n) integers (a_1,a_2,\ldots,a_n) within the range ([0,2^{30})). You can spend (1) coin to increase any (a_i) by (1). You can perform this operation any number of times. You need to solve (q) queries; for each query, you are given an integer (c), also in the range ([0,2^{30})). You would like it if there exists a sequence (b) of length (n) with the following properties: For every (1\le i\le n), (0\le b_i\le a_i). (b_1\oplus b_2\oplus\ldots\oplus b_n=c), where (\oplus) denotes the bitwise XOR operation . Please calculate the minimum number of coins you will have to spend, such that there exists a suitable (b). The queries are independent , meaning that any operations you perform on the sequence (a) will not impact future queries. 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 first line of each test case consists of two integers (n,q) ((1\le n\le5\cdot10^5), (1\le q\le5\cdot10^4)) — the length of sequence (a) and the number of queries. The second line of each test case contains (n) integers (a_1,a_2,\ldots,a_n) ((0\le a_i<2^{30})) — the initial sequence (a). Each of the next (q) lines contains a single integer (c) ((0\le c<2^{30})) — the target XOR. It is guaranteed that the sum of (n) over all test cases does not exceed (5\cdot10^5). It is guaranteed that the sum of (q) over all test cases does not exceed (5\cdot10^4). For each query, output a single integer — the minimum coins you will have to spend, such that there exists a suitable (b). In the first test case, we spend (1) coin to increase (a_2) by (1), resulting in sequence (5,8). A suitable (b) would be (1,8). It can be shown one cannot spend less than (1) coin to achieve the objective. In the second test

Tutorials

148452

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
349309386 -firefly- C Nov. 16, 2025, 3:48 p.m. OK C# 13 TESTS 38 499 21913600
349303822 Pekiban C Nov. 16, 2025, 3:33 p.m. OK C++17 (GCC 7-32) TESTS 38 202 0
349293184 nishkarsh C Nov. 16, 2025, 3:09 p.m. OK C++17 (GCC 7-32) TESTS 38 202 0
349315053 WangTianzhuo C Nov. 16, 2025, 4:06 p.m. OK C++17 (GCC 7-32) TESTS 38 202 2048000
349296360 TripleHappy C Nov. 16, 2025, 3:15 p.m. OK C++17 (GCC 7-32) TESTS 38 202 3993600
349310957 wangzha C Nov. 16, 2025, 3:53 p.m. OK C++17 (GCC 7-32) TESTS 38 203 3993600
349318604 Handsome2004 C Nov. 16, 2025, 4:17 p.m. OK C++17 (GCC 7-32) TESTS 38 203 216883200
349348085 num5 C Nov. 16, 2025, 8:53 p.m. OK C++17 (GCC 7-32) TESTS 46 218 0
349319658 SK1PY C Nov. 16, 2025, 4:20 p.m. OK C++17 (GCC 7-32) TESTS 38 218 0
349315769 GILGAMESH C Nov. 16, 2025, 4:08 p.m. OK C++17 (GCC 7-32) TESTS 38 218 102400
349363920 VaHiX C Nov. 17, 2025, 2:36 a.m. OK C++17 (GCC 7-32) TESTS 48 218 4096000
349304438 Richard1211 C Nov. 16, 2025, 3:34 p.m. OK C++20 (GCC 13-64) TESTS 38 124 2150400
349304319 www_bilibili_com C Nov. 16, 2025, 3:34 p.m. OK C++20 (GCC 13-64) TESTS 38 124 2150400
349308633 zltzlt C Nov. 16, 2025, 3:46 p.m. OK C++20 (GCC 13-64) TESTS 38 140 6144000
349306968 MYJBCHX C Nov. 16, 2025, 3:41 p.m. OK C++20 (GCC 13-64) TESTS 38 155 27238400
349365130 Farmer_D C Nov. 17, 2025, 2:58 a.m. OK C++20 (GCC 13-64) TESTS 48 156 6553600
349312118 ORzyzRO C Nov. 16, 2025, 3:56 p.m. OK C++20 (GCC 13-64) TESTS 38 156 7987200
349345309 -VM- C Nov. 16, 2025, 8:10 p.m. OK C++20 (GCC 13-64) TESTS 43 171 0
349311393 sysu_yzc C Nov. 16, 2025, 3:54 p.m. OK C++20 (GCC 13-64) TESTS 38 171 0
349306460 noya2 C Nov. 16, 2025, 3:40 p.m. OK C++20 (GCC 13-64) TESTS 38 171 0
349299773 mtsd C Nov. 16, 2025, 3:23 p.m. OK C++20 (GCC 13-64) TESTS 38 171 0
349336804 visho33 C Nov. 16, 2025, 6:30 p.m. OK C++23 (GCC 14-64, msys2) TESTS 42 155 204800
349360125 Tamatem.1 C Nov. 17, 2025, 1:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 48 171 0
349319298 isaf27 C Nov. 16, 2025, 4:19 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 171 0
349311750 askd C Nov. 16, 2025, 3:55 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 171 0
349305395 I.Gleb C Nov. 16, 2025, 3:37 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 171 0
349304808 Aile41 C Nov. 16, 2025, 3:35 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 171 0
349341052 brooks72 C Nov. 16, 2025, 7:16 p.m. OK C++23 (GCC 14-64, msys2) TESTS 43 171 204800
349320527 petamingks C Nov. 16, 2025, 4:23 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 171 204800
349319748 ajinkya1p3 C Nov. 16, 2025, 4:21 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 171 2048000
349294787 PinkieRabbit C Nov. 16, 2025, 3:12 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 171 2048000
349380081 SayAnAditya_1by0 C Nov. 17, 2025, 6:02 a.m. OK GNU C11 TESTS 50 1093 4096000
349319801 khuepr123 C Nov. 16, 2025, 4:21 p.m. OK Haskell TESTS 40 1967 53657600
349310577 nathanballman C Nov. 16, 2025, 3:52 p.m. OK Java 21 TESTS 38 515 1433600
349302639 iamalizaidi C Nov. 16, 2025, 3:30 p.m. OK Java 21 TESTS 38 639 5529600
349307733 anshwww C Nov. 16, 2025, 3:43 p.m. OK Java 21 TESTS 38 734 5427200
349296340 gua069 C Nov. 16, 2025, 3:15 p.m. OK Java 8 TESTS 38 343 0
349294026 Tlatoani C Nov. 16, 2025, 3:10 p.m. OK Kotlin 2.2 TESTS 38 593 29081600
349350595 snokes C Nov. 16, 2025, 9:39 p.m. OK PyPy 3 TESTS 47 937 35532800
349318739 detteiuu C Nov. 16, 2025, 4:18 p.m. OK PyPy 3-64 TESTS 38 421 51200000
349296607 chinerist C Nov. 16, 2025, 3:16 p.m. OK PyPy 3-64 TESTS 38 452 52838400
349287437 alexwice C Nov. 16, 2025, 2:58 p.m. OK PyPy 3-64 TESTS 38 468 48230400
349335682 krism C Nov. 16, 2025, 6:21 p.m. OK PyPy 3-64 TESTS 42 468 49971200
349300865 gawkmaster069 C Nov. 16, 2025, 3:25 p.m. OK PyPy 3-64 TESTS 38 468 51814400
349314171 eepsilon C Nov. 16, 2025, 4:03 p.m. OK PyPy 3-64 TESTS 38 468 52224000
349292017 x3x3 C Nov. 16, 2025, 3:06 p.m. OK PyPy 3-64 TESTS 38 546 58572800
349322360 toam C Nov. 16, 2025, 4:29 p.m. OK PyPy 3-64 TESTS 38 561 56320000
349293721 Nolirue_Sola C Nov. 16, 2025, 3:10 p.m. OK PyPy 3-64 TESTS 38 561 58675200
349308515 Ayis137 C Nov. 16, 2025, 3:45 p.m. OK PyPy 3-64 TESTS 38 562 58777600
349305046 sansen C Nov. 16, 2025, 3:36 p.m. OK Rust 2021 TESTS 38 140 7270400
349288102 Monster027 C Nov. 16, 2025, 2:59 p.m. OK Rust 2024 TESTS 38 155 3379200
349366247 123gjweq2 C Nov. 17, 2025, 3:17 a.m. OK Rust 2024 TESTS 48 500 12185600

remove filters

Back to search problems