Codeforces Round 982 (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
2027 Codeforces Round 982 (Div. 2) FINISHED False 7200 46452323 Oct. 26, 2024, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 109 ) E2 Bit Game (Hard Version) PROGRAMMING bitmasks dp math

This is the hard version of this problem. The only difference is that you need to output the number of choices of games where Bob wins in this version, where the number of stones in each pile are not fixed. You must solve both versions to be able to hack. Alice and Bob are playing a familiar game where they take turns removing stones from (n) piles. Initially, there are (x_i) stones in the (i)-th pile, and it has an associated value (a_i). A player can take (d) stones away from the (i)-th pile if and only if both of the following conditions are met: (1 \le d \le a_i), and (x \, \& \, d = d), where (x) is the current number of stones in the (i)-th pile and (\&) denotes the bitwise AND operation . The player who cannot make a move loses, and Alice goes first. You're given the (a_i) values of each pile, but the number of stones in the (i)-th pile has not been determined yet. For the (i)-th pile, (x_i) can be any integer between (1) and (b_i), inclusive. That is, you can choose an array (x_1, x_2, \ldots, x_n) such that the condition (1 \le x_i \le b_i) is satisfied for all piles. Your task is to count the number of games where Bob wins if both players play optimally. Two games are considered different if the number of stones in any pile is different, i.e., the arrays of (x) differ in at least one position. Since the answer can be very large, please output the result modulo (10^9 + 7). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 1000)). The description of the test cases follows. The first line of each test case contains (n) ((1 \le n \le 10^4)) — the number of piles. The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \le a_i < 2^{30})). The third line of each test case contains (n) integers (b_1, b_2, \ldots, b_n) ((1 \le b_i < 2^{30})). It is

Tutorials

Codeforces Round #982 (Div. 2) Editorial

Submissions

No solutions yet.