atcoder#AGC055C. [AGC055C] Weird LIS
[AGC055C] Weird LIS
Score : points
Problem Statement
You are given integers and . Find the number of arrays of length such that the following conditions hold:
- ()
- There exists a permutation of integers from to with the following property:- For every from to , equals the length of the longest increasing subsequence of the sequence $[P_1, P_2, \ldots, P_{i-1}, P_{i+1}, \ldots, P_{N-1}, P_N]$.
- For every from to , equals the length of the longest increasing subsequence of the sequence $[P_1, P_2, \ldots, P_{i-1}, P_{i+1}, \ldots, P_{N-1}, P_N]$.
As this number can be very large, output it modulo some prime .
Constraints
- .
- .
- is a prime.
Input
Input is given from Standard Input in the following format:
Output
Print the answer modulo .
3 2 686926217
1
The only such array is , for which exists a permutation .
4 3 354817471
9
There are such arrays: , , , , , , , , .
5 2 829412599
1
The only such array is .
5 3 975576997
23
69 42 925171057
801835311