#P8556. Records‐Removal Sequence Count
Records‐Removal Sequence Count
Records‐Removal Sequence Count
Let (p = (p_1, p_2,\dots,p_n)) be a permutation of ({1,2,\dots,n}). For any nonempty sequence (q = (q_1,q_2,\dots,q_l)) we define [ f(q)=#{i:;1\le i\le l,; q_i = \max_{1\le j\le i}q_j},. ] For each (1\le i\le n) define (P_i) as the sequence obtained from (p) by removing its (i)th element. Then we obtain an integer vector (a=(a_1,a_2,\dots,a_n)) where (a_i=f(P_i)).
Given two integers (n) and (m), count the number of distinct sequences (a) of length (n) with each (a_i) satisfying (m\le a_i\le n) for which there exists a permutation (p) with the property that for every (1\le i\le n), (a_i=f(P_i)).
Since the answer can be large, output it modulo (10^9+7).
Note on notation: All formulas are written in (\LaTeX) format.
Remark: It can be proved that for any permutation (p), the value (f(P_i)) always lies between 1 and (n-1) (with the only exception when (n=1), in which case we define (f(\emptyset)=0)). Thus, if (m\ge n) (or in the case (n=1) when (m>0)), no valid sequence (a) exists.
inputFormat
The input consists of a single line containing two integers (n) and (m) (with (1\le n\le 8)) separated by a space. (Note: Due to the combinatorial nature of the problem, we assume (n) is small.)
outputFormat
Output a single integer, the number of distinct sequences (a=(a_1,a_2,\dots,a_n)) achievable by some permutation (p) such that (m\le a_i\le n) for all (i), modulo (10^9+7).
sample
2 1
1