AtCoder Grand Contest 055
翻译中…
Problem Statement
翻译中…
You are given integers $N$ and $M$. Find the number of arrays $A=[A_1, A_2, \ldots, A_N]$ of length $N$ such that the following conditions hold:
翻译中…
$2 \le A_i \le M$($1 \leq i \leq N$)- There exists a permutation
$P=[P_1,P_2,\ldots,P_N]$of integers from$1$to$N$with the following property: - For every
$i$from$1$to$N$,$A_i$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 $Q$.
翻译中…
Constraints
翻译中…
$3 \le N \le 5000$.$2 \le M \le N-1$.$10^8 \le Q \le 10^9$$Q$is a prime.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N M Q
翻译中…
Output
翻译中…
Print the answer modulo $Q$.
翻译中…
样例
Input #1
3 2 686926217
Output #1
1
The only such array is $[2, 2, 2]$, for which exists a permutation $[1, 2, 3]$.
Input #2
4 3 354817471
Output #2
9
There are $9$ such arrays: $[2, 2, 2, 2]$, $[2, 2, 2, 3]$, $[2, 2, 3, 2]$, $[2, 2, 3, 3]$, $[2, 3, 2, 2]$, $[2, 3, 3, 2]$, $[3, 2, 2, 2]$, $[3, 3, 2, 2]$, $[3, 3, 3, 3]$.
Input #3
5 2 829412599
Output #3
1
The only such array is $[2, 2, 2, 2, 2]$.
Input #4
5 3 975576997
Output #4
23
Input #5
69 42 925171057
Output #5
801835311
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。