cswork / OA打开练习工作台

AmazonOA #144

Find Dominance

估计中等可在线判题

考点(AI 标注)字典树序列化哈希计数

n strings all have length m. For each length 1..m, find how many times the most frequent prefix occurs; duplicate strings are counted as separate input records, and only the count is output, not the prefix.

输入格式

The first line contains n m, followed by n strings of equal length. The source has 2≤n≤500 and 1≤m≤2000; the source does not restrict the character set, and this site uses lowercase letters.

输出格式

Output m maximum occurrence counts for prefix lengths 1..m in order.

样例 1

输入:

3 3
aba
abb
aba

输出:

3 3 2

样例 2

输入:

3 3
abc
aaa
aba

输出:

3 2 1

样例 3

输入:

2 2
aa
aa

输出:

2 2

样例说明

Example 1: a and ab each occur 3 times, and aba occurs 2 times, so output 3 3 2. Example 2: the first letter a occurs 3 times, ab 2 times, and each full string once, so output 3 2 1. Example 3: the prefixes of both lengths occur 2 times, so output 2 2.