Posts

Count of Array

  You love array, don't you? You are given two integer  N N  and  M M , along with an array  B B  of length  N N  containing  pairwise distinct  integers. You have to find the number of array  A A  of length  N N  satisfying the follow conditions: 1 ≤ A i ≤ M 1 ≤ A i ≤ M . A i ≠ A j A i ≠ A j  for all  1 ≤ i < j ≤ N 1 ≤ i < j ≤ N . A i ≠ B i A i ≠ B i  for all  1 ≤ i ≤ N 1 ≤ i ≤ N . Since the answer can be very large, output it under modulo  10 9 + 7 10 9 + 7 . Input Format The first line of the input contains two space-separated integers  N N  and  M M . The second line of the input contains  N N  separated integers  B 1 , B 2 , … , B N B 1 , B 2 , … , B N  - the array  B B . Output Format Output on a single line the number of satisfactory array modulo  10 9 + 7 10 9 + 7 . Constraints 1 ≤ N ≤ 2 ⋅ 10 5 1 ≤ N ≤ 2 ⋅ 10 5 1 ≤ M ≤ 3 ⋅ 10 5 1 ≤ M ≤...