| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 5 초 | 2048 MB | 1 | 1 | 1 | 100.000% |
For a permutation $p = p[0] p[1] p[2] \dots p[n − 1]$ of the numbers $1, 2, 3,\dots,n$ we define a split as a permutation $q$ which can be obtained by the following process:
Moreover, we define $S(p)$ to be the set of all splits of a permutation $p$.
You are given a number $n$ and a set $T$ of $m$ permutations of length $n$. Count how many permutations $p$ of length $n$ exist such that $T ⊆ S(p)$. Since this number can be large, find it modulo $998\, 244\, 353$.
You should implement the following procedure:
int solve(int n, int m, std::vector<std::vector<int>>& splits);
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 6 | $m = 1$ |
| 2 | 7 | $1 ≤ n,m ≤ 10$ |
| 3 | 17 | $1 ≤ n,m ≤ 18$ |
| 4 | 17 | $1 ≤ n ≤ 30$, $1 ≤ m ≤ 15$ |
| 5 | 16 | $1 ≤ n,m ≤ 90$ |
| 6 | 16 | $1 ≤ n ≤ 300$, $1 ≤ m ≤ 15$ |
| 7 | 21 | No additional constraints. |
Example 1
Consider the following call:
solve(3, 2, {{1, 2, 3}, {2, 1, 3}})
In this sample, the size of the permutation $p$ is $3$ and we are given $2$ splits:
The function call will return $4$ as there are only four permutations $p$ that can generate both of those splits:
The sample grader reads the input in the following format:
and outputs the result of the call to solve with the corresponding parameters.
C++17, C++20, C++23, C++26, C++17 (Clang), C++20 (Clang)