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 |
|---|---|---|---|---|---|---|
| 2159 | Codeforces Round 1058 (Div. 1) | FINISHED | False | 9000 | 16125923 | Oct. 12, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 1672 ) | C | Twin Polynomials | PROGRAMMING | combinatorics graph matchings graphs math |
A polynomial (f(x) = a_0 + a_1x + a_2x^2 + \ldots + a_nx^n) is called a valid polynomial of degree (n) if and only if (a_i) is a non-negative integer for all (0 \le i \le n) and (a_n) is not (0). For a valid polynomial (f(x) = a_0 + a_1x + a_2x^2 + \ldots + a_nx^n) of degree (n), its twin polynomial (g(x)) is defined as: () g(x) = \sum_{i=0}^n i \cdot x^{a_i} () For example, for (f(x) = 1 + 2x + 2x^3), its twin polynomial is: () g(x) = 0 \cdot x^{1} + 1 \cdot x^{2} + 2 \cdot x^{0} + 3 \cdot x^{2} = 0+x^2+2+3x^2= 2 + 4x^2 () A valid polynomial (f(x)) of degree (n) is called cool if and only if (f(x) = g(x)). In other words, a valid polynomial of degree (n) is cool if and only if its twin polynomial equals itself. You are given an incomplete valid polynomial (f(x) = a_0 + a_1x + a_2x^2 + \ldots + a_nx^n) of degree (n). Some of (a_i) have been determined, while others have not been determined. Additionally , it is guaranteed that (a_0) and (a_n) are not determined . Please count the number of cool valid polynomials of degree (n) that can be found by determining all undetermined (a_i)'s. Since the answer may be large, you need to output it modulo (1\,000\,000\,007). 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. For each test case, the first line contains an integer (n) ((1 \leq n \leq 4 \cdot 10^5)). The second line contains (n+1) integers (a_0, a_1, \ldots, a_n) ((-1 \leq a_i \leq 10^9)). Here, (a_i=-1) means (a_i) has not been determined, while (a_i \neq -1) means (a_i) has been determined as its value. It is guaranteed that (a_0) and (a_n) are always (-1) in the input. It is guaranteed that the sum of (n) over all test cases does not exceed (4 \cdot 10^5). For each test case, output |
| Codeforces Round 1058 Editorial |
No solutions yet.