atcoder#ARC104E. [ARC104E] Random LIS
[ARC104E] Random LIS
Score : points
Problem Statement
Given is an integer sequence of length : .
An integer sequence , which is also of length , will be chosen randomly by independently choosing from a uniform distribution on the integers for each .
Compute the expected value of the length of the longest increasing subsequence of this sequence , modulo .
More formally, under the constraints of the problem, we can prove that the expected value can be represented as a rational number, that is, an irreducible fraction , and there uniquely exists an integer such that and , so print this integer .
Notes
A subsequence of a sequence is a sequence obtained by extracting some of the elements of and arrange them without changing the order. The longest increasing subsequence of a sequence is the sequence of the greatest length among the strictly increasing subsequences of .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the expected value modulo .
3
1 2 3
2
becomes one of the following, with probability for each:
- , for which the length of the longest increasing subsequence is ;
- , for which the length of the longest increasing subsequence is ;
- , for which the length of the longest increasing subsequence is ;
- , for which the length of the longest increasing subsequence is ;
- , for which the length of the longest increasing subsequence is ;
- , for which the length of the longest increasing subsequence is .
Thus, the expected value of the length of the longest increasing subsequence is $(1 + 2 + 2 + 2 + 2 + 3) / 6 \equiv 2 \pmod {1000000007}$.
3
2 1 2
500000005
becomes one of the following, with probability for each:
- , for which the length of the longest increasing subsequence is ;
- , for which the length of the longest increasing subsequence is ;
- , for which the length of the longest increasing subsequence is ;
- , for which the length of the longest increasing subsequence is .
Thus, the expected value of the length of the longest increasing subsequence is . Since , we should print .
6
8 6 5 10 9 14
959563502