GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Sunday, 8 May 2022

Tokitsukaze and Permutations Codeforces Solution | Codeforces Problem Solution 2022

F. Tokitsukaze and Permutations
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Tokitsukaze has a permutation p. She performed the following operation to p exactly k times: in one operation, for each i from 1 to n1 in order, if pi > pi+1, swap pipi+1. After exactly k times of operations, Tokitsukaze got a new sequence a, obviously the sequence a is also a permutation.

After that, Tokitsukaze wrote down the value sequence v of a on paper. Denote the value sequence v of the permutation a of length n as vi=j=1i1[ai<aj], where the value of [ai<aj] define as if ai<aj, the value is 1, otherwise is 0 (in other words, vi is equal to the number of elements greater than ai that are to the left of position i). Then Tokitsukaze went out to work.

Solution Click Below:-  CLICK HERE

There are three naughty cats in Tokitsukaze's house. When she came home, she found the paper with the value sequence v 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 p 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 p there are, so that the value sequence v of the new permutation a after exactly k operations is the same as the v written on the paper (not taking into account the unclear positions).

Since the answer may be too large, print it modulo 998244353.

Input

The first line contains a single integer t (1t1000) — the number of test cases. Each test case consists of two lines.

The first line contains two integers n and k (1n1060kn1) — the length of the permutation and the exactly number of operations.

The second line contains n integers v1,v2,,vn (1vii1) — the value sequence vvi=1 means the i-th position of v can't be seen clearly.

It is guaranteed that the sum of n over all test cases does not exceed 106.

Output

For each test case, print a single integer — the number of different permutations modulo 998244353.


Join Now for Solution:- 

No comments:

Post a Comment