[Solution] Yet Another Array Counting Problem Codeforces Solution
The position of the leftmost maximum on the segment of array is the smallest integer such that and .
You are given an array of length . Find the number of integer arrays of length that satisfy the following conditions:
- for all ;
- for all pairs of integers , the position of the leftmost maximum on the segment of the array is equal to the position of the leftmost maximum on the segment of the array .
Since the answer might be very large, print its remainder modulo .
Each test contains multiple test cases. The first line contains a single integer () — the number of test cases.
The first line of each test case contains two integers and (, ).
The second line of each test case contains integers () — the array .
It is guaranteed that the sum of over all test cases doesn't exceed .
For each test case print one integer — the number of arrays that satisfy the conditions from the statement, modulo .
In the first test case, the following arrays satisfy the conditions from the statement:
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- .
In the second test case, the following arrays satisfy the conditions from the statement:
- ;
- ;
- ;
- ;
No comments:
Post a Comment