Codeforces Round 1123 (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
2267 Codeforces Round 1123 (Div. 2) FINISHED False 8100 833066 Sept. 25, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 775 ) F2 XOR Transformations (Hard Version) PROGRAMMING bitmasks brute force data structures greedy strings trees

This is the hard version of the problem. The difference between the versions is that in this version, the constraints on (n) and (q) are higher. You can make hacks only if you have solved all versions of this problem. For an array (b) consisting of (m) integers, define a transformation as follows: Write down the values (b_i\oplus b_j) for all (1\le i\lt j\le m), where (\oplus) denotes the bitwise XOR operation . Take the (m) smallest among the written values. Replace the elements of the array with the taken (m) values. For example, consider the transformation of the array (6, 7, 8, 9, 15). We write down the values (1, 1, 6, 7, 8, 9, 14, 14, 15, 15). After the transformation , the array becomes (1, 1, 6, 7, 8) — the (5) smallest elements. You are given an array (a) consisting of (n) non-negative integers. Let (\max(a)) denote the maximum element of the array (a), and (\min(a)) — the minimum. Your task is to answer (q) queries, each of which gives you one integer (x). For each query, find the value of (\max(a) - \min(a)) after (x) transformations on the array. Note that the queries are independent, i.e. before each query, the array (a) is restored to its original state. 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 contains two integers (n) and (q) ((5\le n\le 10^5, 1\le q\le 10^5)) — the size of the array 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\lt 2^{30})). The next (q) lines of each test case contain an integer (x) ((0\le x\lt 2^{30})). It is guaranteed that the sum of (n) and the sum of (q) over all test cases do not exceed (10^5). For each test case, print (q) integers — the answer

Tutorials

157126

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
392070706 houyhl F2 Sept. 25, 2026, 4:49 p.m. OK C++17 (GCC 7-32) TESTS 61 156 3276800
392106225 _Mohammed_Yasser_ F2 Sept. 26, 2026, 3:58 a.m. OK C++17 (GCC 7-32) TESTS 67 296 102400
392060382 jisoofan F2 Sept. 25, 2026, 4:20 p.m. OK C++17 (GCC 7-32) TESTS 61 312 48128000
392067211 Crowceit F2 Sept. 25, 2026, 4:40 p.m. OK C++17 (GCC 7-32) TESTS 61 375 39014400
392070007 aoteyingtian666 F2 Sept. 25, 2026, 4:48 p.m. OK C++17 (GCC 7-32) TESTS 61 390 115814400
392105654 HoshiYougi F2 Sept. 26, 2026, 3:46 a.m. OK C++17 (GCC 7-32) TESTS 67 406 40857600
392073240 cpc_gallos F2 Sept. 25, 2026, 5:14 p.m. OK C++17 (GCC 7-32) TESTS 61 437 69427200
392062574 Bug__Exorcist F2 Sept. 25, 2026, 4:26 p.m. OK C++17 (GCC 7-32) TESTS 61 531 37273600
392083105 XZ_7 F2 Sept. 25, 2026, 6:57 p.m. OK C++17 (GCC 7-32) TESTS 66 656 62156800
392068219 jiufeng F2 Sept. 25, 2026, 4:43 p.m. OK C++17 (GCC 7-32) TESTS 61 656 62156800
392062764 dosifey67 F2 Sept. 25, 2026, 4:27 p.m. OK C++20 (GCC 13-64) TESTS 61 109 0
392087752 alternn F2 Sept. 25, 2026, 8:07 p.m. OK C++20 (GCC 13-64) TESTS 67 140 0
392109767 Recolve F2 Sept. 26, 2026, 4:57 a.m. OK C++20 (GCC 13-64) TESTS 67 156 3993600
392079833 ALAov F2 Sept. 25, 2026, 6:17 p.m. OK C++20 (GCC 13-64) TESTS 66 187 0
392061586 jianglin2010 F2 Sept. 25, 2026, 4:23 p.m. OK C++20 (GCC 13-64) TESTS 61 250 1638400
392069466 zy2022 F2 Sept. 25, 2026, 4:46 p.m. OK C++20 (GCC 13-64) TESTS 61 281 12800000
392081449 limif F2 Sept. 25, 2026, 6:35 p.m. OK C++20 (GCC 13-64) TESTS 66 390 39321600
392106648 lingzihaojoe F2 Sept. 26, 2026, 4:07 a.m. OK C++20 (GCC 13-64) TESTS 67 390 82636800
392072854 parkky F2 Sept. 25, 2026, 5:12 p.m. OK C++20 (GCC 13-64) TESTS 61 406 0
392083088 jabiryimam1 F2 Sept. 25, 2026, 6:56 p.m. OK C++20 (GCC 13-64) TESTS 66 406 48435200
392070823 Sensity F2 Sept. 25, 2026, 4:49 p.m. OK C++23 (GCC 14-64, msys2) TESTS 61 93 0
392108518 wmq9527 F2 Sept. 26, 2026, 4:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 67 125 0
392087695 sidat F2 Sept. 25, 2026, 8:06 p.m. OK C++23 (GCC 14-64, msys2) TESTS 67 125 1126400
392068360 AlphaBruh F2 Sept. 25, 2026, 4:43 p.m. OK C++23 (GCC 14-64, msys2) TESTS 61 125 2048000
392067970 somyalsinha F2 Sept. 25, 2026, 4:42 p.m. OK C++23 (GCC 14-64, msys2) TESTS 61 140 0
392115310 Nyemot F2 Sept. 26, 2026, 5:53 a.m. OK C++23 (GCC 14-64, msys2) TESTS 67 156 1126400
392114363 Nyemot F2 Sept. 26, 2026, 5:45 a.m. OK C++23 (GCC 14-64, msys2) TESTS 67 156 1126400
392112466 Nyemot F2 Sept. 26, 2026, 5:28 a.m. OK C++23 (GCC 14-64, msys2) TESTS 67 156 5324800
392100977 ccj123 F2 Sept. 26, 2026, 1:53 a.m. OK C++23 (GCC 14-64, msys2) TESTS 67 156 62566400
392115799 Nyemot F2 Sept. 26, 2026, 5:57 a.m. OK C++23 (GCC 14-64, msys2) TESTS 67 171 0
392065146 Gassa F2 Sept. 25, 2026, 4:34 p.m. OK D TESTS 61 1000 35635200
392086934 TripleM5da F2 Sept. 25, 2026, 7:54 p.m. OK Go TESTS 66 2140 270336000
392077174 TripleM5da F2 Sept. 25, 2026, 5:50 p.m. OK Go TESTS 65 3515 294502400
392067261 aaryannage.dev F2 Sept. 25, 2026, 4:40 p.m. OK Java 21 TESTS 61 500 14950400
392107028 dakshgupta2610 F2 Sept. 26, 2026, 4:14 a.m. OK Java 21 TESTS 67 1062 43008000
392059397 rahulx1515 F2 Sept. 25, 2026, 4:17 p.m. OK Java 21 TESTS 61 1546 70246400
392064920 techbro815 F2 Sept. 25, 2026, 4:33 p.m. OK Java 21 TESTS 61 1687 68812800
392059820 harsh1604 F2 Sept. 25, 2026, 4:18 p.m. OK Java 21 TESTS 61 1734 83148800
392059913 winanhle F2 Sept. 25, 2026, 4:19 p.m. OK Java 21 TESTS 61 2703 117452800
392064287 sirwagya F2 Sept. 25, 2026, 4:31 p.m. OK Java 21 TESTS 61 2890 69632000
392062577 ASM3456 F2 Sept. 25, 2026, 4:26 p.m. OK Java 21 TESTS 61 3656 124928000
392067241 LiveisFPV F2 Sept. 25, 2026, 4:40 p.m. OK PyPy 3-64 TESTS 61 593 17612800
392066381 the_seal F2 Sept. 25, 2026, 4:38 p.m. OK PyPy 3-64 TESTS 61 1640 55705600
392063181 DarkShadowWinner F2 Sept. 25, 2026, 4:28 p.m. OK PyPy 3-64 TESTS 61 3234 74444800
392058443 goshan_17 F2 Sept. 25, 2026, 4:15 p.m. OK PyPy 3-64 TESTS 61 3484 72601600
392070774 Pulkit_gupta F2 Sept. 25, 2026, 4:49 p.m. OK PyPy 3-64 TESTS 61 3640 274022400
392064913 sh20raj F2 Sept. 25, 2026, 4:33 p.m. OK Python 3 TESTS 61 1468 54886400
392062831 amanchourasia F2 Sept. 25, 2026, 4:27 p.m. OK Rust 2024 TESTS 61 437 38604800
392104282 NNChen F2 Sept. 26, 2026, 3:18 a.m. OK Rust 2024 TESTS 67 484 40960000
392070820 HigherOrderLogic F2 Sept. 25, 2026, 4:49 p.m. OK Rust 2024 TESTS 61 578 62873600

remove filters

Back to search problems