Longest Common Subsequence
题号:NC52865
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 32 M,其他语言64 M
Special Judge, 64bit IO Format: %lld

题目描述

Bobo has a sequence of length n.
He would like to know f(0), f(1), f(2) and f(3) where f(k) denotes the number of integer sequences where:
* ;
* The length of longest common subsequence of A and X is exactly k.

Note:
* u is a subsequence of v if and only if u can be obtained by removing some of the entries from v (possibly none).
* u is common subsequence of v and w if and only if u is subsequence of v and w.

输入描述:

The input contains zero or more test cases and is terminated by end-of-file. For each case,
The first line contains two integers n, m.
The second line contains n integers .

*
*
* The number of tests cases does not exceed 10.

输出描述:

For each case, output four integers which denote f(0), f(1), f(2), f(3).
示例1

输入

复制
3 3
1 2 2
5 3
1 2 3 2 1

输出

复制
1 14 11 1
0 1 17 9

备注:

For the second sample, X = (3, 3, 3) is the only sequence that the length of longest common subsequence of A and X is 1.
Thus, f(1) = 1.