Codeforces Round 1045 (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
2134 Codeforces Round 1045 (Div. 2) FINISHED False 7200 20186723 Aug. 26, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 640 ) F Permutation Oddness PROGRAMMING combinatorics dp

You are given four positive integers (c_0), (c_1), (c_2), and (c_3). Let (n = c_0 + c_1 + c_2 + c_3). Consider an array (a) of (n) integers with (x) ((0\le x\le 3)) appearing (c_x) times. For any distinct permutation (^{\text{∗}}) (b) of the array (a), define its oddness as(^{\text{†}})(^{\text{‡}}): ()\sum_{i = 1}^{n-1} \text{lowbit}(b_i \oplus b_{i+1})() Your task is to count, for each integer (k) from (0) to (2 \cdot (n-1)) (inclusive), the number of distinct permutations of (a) with an oddness equal to (k). Since the numbers might be too large, you are only required to find them modulo (10^9 + 7). (^{\text{∗}})A permutation of the array is an arrangement of its elements into any order. For example, (1,2,2) is a permutation of (2,2,1), but (1,1,2) is not. Two permutations are considered distinct if they differ in at least one position. (^{\text{†}})(\oplus) denotes the bitwise XOR operation . (^{\text{‡}})(\text{lowbit}(x)) is the value of the lowest binary bit of (x), e.g. (\text{lowbit}(12)=4), (\text{lowbit}(8)=8). Specifically, we define (\text{lowbit}(0) = 0). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 50)). The description of the test cases follows. The first and the only line of each test case contains four positive integers (c_0), (c_1), (c_2), and (c_3) ((1 \le c_0, c_1, c_2, c_3 < 800), (4 \le c_0 + c_1 + c_2 + c_3 \le 800)). Let (n = c_0 + c_1 + c_2 + c_3). It is guaranteed that the sum of (n) over all test cases does not exceed (800). For each test case, output (2 \cdot (n-1) + 1) integers in one line — the number of distinct permutations of (a) with an oddness equal to (0,1,\ldots, 2 \cdot (n-1)) respectively. Output the answers modulo (10^9+7). In the first test case, the ar

Tutorials

145832

Submissions

No solutions yet.