Codeforces Round 553 (Div. 2)
F
Sonya and Informatics
Codeforces
2300
原题
← E→
翻译中…

A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.

翻译中…

Given an array $a$ of length $n$, consisting only of the numbers $0$ and $1$, and the number $k$. Exactly $k$ times the following happens:

翻译中…
  • Two numbers $i$ and $j$ are chosen equiprobable such that ($1 \leq i \lt j \leq n$).
  • The numbers in the $i$ and $j$ positions are swapped.
翻译中…

Sonya's task is to find the probability that after all the operations are completed, the $a$ array will be sorted in non-decreasing order. She turned to you for help. Help Sonya solve this problem.

翻译中…

It can be shown that the desired probability is either $0$ or it can be represented as $\dfrac{P}{Q}$, where $P$ and $Q$ are coprime integers and $Q \not\equiv 0~\pmod {10^9+7}$.

翻译中…

Input

翻译中…

The first line contains two integers $n$ and $k$ ($2 \leq n \leq 100, 1 \leq k \leq 10^9$) — the length of the array $a$ and the number of operations.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 1$) — the description of the array $a$.

翻译中…

Output

翻译中…

If the desired probability is $0$, print $0$, otherwise print the value $P \cdot Q^{-1}$ $\pmod {10^9+7}$, where $P$ and $Q$ are defined above.

翻译中…

Note

翻译中…

In the first example, all possible variants of the final array $a$, after applying exactly two operations: $(0, 1, 0)$, $(0, 0, 1)$, $(1, 0, 0)$, $(1, 0, 0)$, $(0, 1, 0)$, $(0, 0, 1)$, $(0, 0, 1)$, $(1, 0, 0)$, $(0, 1, 0)$. Therefore, the answer is $\dfrac{3}{9}=\dfrac{1}{3}$.

翻译中…

In the second example, the array will not be sorted in non-decreasing order after one operation, therefore the answer is $0$.

翻译中…

样例

Input #1
3 2
0 1 0
Output #1
333333336
InputCopy OutputCopy
Input #2
5 1
1 1 1 0 0
Output #2
0
InputCopy OutputCopy
Input #3
6 4
1 0 0 1 1 0
Output #3
968493834
InputCopy OutputCopy
题目信息
题号
1151F
时间限制
1 s
内存限制
256 MB
标签
组合数学
动态规划
矩阵
概率论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。