Tokitsukaze and Permutations Codeforces Solution | Codeforces Problem Solution 2022
Tokitsukaze has a permutation . She performed the following operation to exactly times: in one operation, for each from to in order, if > , swap , . After exactly times of operations, Tokitsukaze got a new sequence , obviously the sequence is also a permutation.
After that, Tokitsukaze wrote down the value sequence of on paper. Denote the value sequence of the permutation of length as , where the value of define as if , the value is , otherwise is (in other words, is equal to the number of elements greater than that are to the left of position ). Then Tokitsukaze went out to work.
There are three naughty cats in Tokitsukaze's house. When she came home, she found the paper with the value sequence to be bitten out by the cats, leaving several holes, so that the value of some positions could not be seen clearly. She forgot what the original permutation was.
[Solution] Tokitsukaze and Good 01-String
Tokitsukaze and Two Colorful Tapes Codeforces Solution
Tokitsukaze and Permutations Codeforces Solution
She wants to know how many different permutations there are, so that the value sequence of the new permutation after exactly operations is the same as the written on the paper (not taking into account the unclear positions).
Since the answer may be too large, print it modulo .
The first line contains a single integer () — the number of test cases. Each test case consists of two lines.
The first line contains two integers and (; ) — the length of the permutation and the exactly number of operations.
The second line contains integers () — the value sequence . means the -th position of can't be seen clearly.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print a single integer — the number of different permutations modulo .
Join Now for Solution:-
No comments:
Post a Comment