#P13694. [CEOI 2025] Splits
[CEOI 2025] Splits
题目描述
For a permutation of the numbers we define a split as a permutation which can be obtained by the following process:
- Select two sets of numbers and such that , , and
- The permutation will be $q = p[i_1] p[i_2] \ldots p[i_k] p[j_1] p[j_2] \ldots p[j_l]$
Moreover, we define to be the set of all splits of a permutation .
You are given a number and a set of permutations of length . Count how many permutations of length exist such that . Since this number can be large, find it modulo .
Implementation Details
You should implement the following procedure:
int solve(int n, int m, std::vector<std::vector<int>>& splits);
- : the size of the permutation
- : the number of splits
- : array containing pairwise distinct permutations, the elements of the set , which is a subset of
This procedure should return the number of possible permutations modulo . This procedure is called exactly once for each test case.
3 2
1 2 3
2 1 3
4
提示
Sample Explanation 1
Consider the following call:
solve(3, 2, {{1, 2, 3}, {2, 1, 3}})
In this sample, the size of the permutation is and we are given splits:
The function call will return as there are only four permutations that can generate both of those splits:
Constraints
Subtasks
- (6 points)
- (7 points)
- (17 points)
- (17 points)
- (16 points)
- (16 points)
- (21 points) No additional constraints.