Codeforces Round 1078 (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
2194 Codeforces Round 1078 (Div. 2) FINISHED False 7200 5864123 Feb. 8, 2026, 9:05 a.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 166 ) F2 Again Trees... (hard version) PROGRAMMING bitmasks data structures dfs and similar dp fft trees

This is the hard version of the problem. The difference between the versions is that in this version, (k \leq 10). You can hack only if you solved all versions of this problem. Given a tree consisting of (n) vertices. Each vertex has a non-negative integer (a_v) written on it. You are also given (k) distinct non-negative integers (b_1, \ldots, b_k). We will call a set of edges beautiful if, after removing these edges from the tree, the tree splits into connected components, where in each component the bitwise XOR of all the numbers (a_v) in that component belongs to the set (b). You need to count the number of beautiful sets of edges in the tree modulo (10^9 + 7). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 500)). The description of the test cases follows. The first line of each dataset contains two integers (n) and (k) ((2 \leq n \leq 10^5), (1 \leq k \leq 10)) — the number of vertices in the tree and the size of the set (b). The next (n - 1) lines describe the edges of the tree. The (i)-th line contains two integers (v_i) and (u_i) ((1 \leq v_i, u_i \leq n)) — the numbers of the vertices connected by the (i)-th edge. The next line contains (n) integers (a_1, a_2, \ldots, a_n) ((0 \leq a_i \lt 2^{30})) — the values written on the vertices. The following line contains (k) distinct integers (b_1, b_2, \ldots, b_k) ((0 \leq b_i \lt 2^{30})) — the elements of the set (b). It is guaranteed that the sum of (n) across all datasets does not exceed (10^5). For each test dataset, output a single integer — the answer to the problem. Illustration for the first test dataset. In it, you can remove the edge between vertices (1) and (2). Then the bitwise XOR in the component consisting of vertices (2) and (5) is (a_2 \oplus a_5 = 2 \oplus 3 = 1). The bitwise XOR in the co

Tutorials

Codeforces Round #1078 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
362022953 buitS F2 Feb. 8, 2026, 3:15 p.m. OK C++17 (GCC 7-32) TESTS 53 656 322457600
362073538 Satyam2106 F2 Feb. 9, 2026, 4:07 a.m. OK C++17 (GCC 7-32) TESTS 59 671 459161600
361995998 Acheronlt F2 Feb. 8, 2026, 10:56 a.m. OK C++20 (GCC 13-64) TESTS 53 578 152064000
362028689 DuanQingQiu F2 Feb. 8, 2026, 4:01 p.m. OK C++20 (GCC 13-64) TESTS 53 640 417177600
362071042 re__xyx F2 Feb. 9, 2026, 3:21 a.m. OK C++20 (GCC 13-64) TESTS 58 765 442572800
361997272 EnofTaiPeople F2 Feb. 8, 2026, 10:59 a.m. OK C++20 (GCC 13-64) TESTS 53 828 493772800
361998758 gargaayush686 F2 Feb. 8, 2026, 11:02 a.m. OK C++20 (GCC 13-64) TESTS 53 890 294400000
362063736 xvtianze F2 Feb. 9, 2026, 12:12 a.m. OK C++20 (GCC 13-64) TESTS 58 890 435916800
361994820 BennyLaw F2 Feb. 8, 2026, 10:53 a.m. OK C++20 (GCC 13-64) TESTS 53 968 437350400
361998345 Ivan_len F2 Feb. 8, 2026, 11:01 a.m. OK C++20 (GCC 13-64) TESTS 53 968 439910400
362066260 zdd6310 F2 Feb. 9, 2026, 1:34 a.m. OK C++20 (GCC 13-64) TESTS 58 968 840499200
362066285 zdd6310 F2 Feb. 9, 2026, 1:34 a.m. OK C++20 (GCC 13-64) TESTS 58 1000 842035200
362051727 jackylova_fan_fan_fan F2 Feb. 8, 2026, 7:36 p.m. OK C++23 (GCC 14-64, msys2) TESTS 57 640 449024000
362030342 The_Mad_Max F2 Feb. 8, 2026, 4:16 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 687 10956800
361995154 LittleLiya F2 Feb. 8, 2026, 10:54 a.m. OK C++23 (GCC 14-64, msys2) TESTS 53 734 297472000
362026595 JessieQY F2 Feb. 8, 2026, 3:43 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 734 414924800
362025508 becaido F2 Feb. 8, 2026, 3:34 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 765 150016000
361993226 Riyuzaki121 F2 Feb. 8, 2026, 10:49 a.m. OK C++23 (GCC 14-64, msys2) TESTS 53 781 149913600
362064921 aoliao_lovely F2 Feb. 9, 2026, 12:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 58 796 428339200
362064833 oryo F2 Feb. 9, 2026, 12:48 a.m. OK C++23 (GCC 14-64, msys2) TESTS 58 796 428339200
362037650 mathiasgw F2 Feb. 8, 2026, 5:10 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 812 415027200
362028342 415411 F2 Feb. 8, 2026, 3:58 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 828 110899200
362063420 sansen F2 Feb. 9, 2026, 12:03 a.m. OK Rust 2021 TESTS 58 625 447180800
361999245 GKarthik26 F2 Feb. 8, 2026, 11:03 a.m. OK Rust 2024 TESTS 53 703 430694400

remove filters

Back to search problems