F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Another String

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 418    Accepted Submission(s): 266


Problem Description
Define the distance between two strings of the same length as the numbers of the positions where the characters differ in these two strings.

If two strings of the same length has a distance of no more than $k$, we call these two string satisfy $k-matching$.

Given a string $S$ of length $n$ and a integer $k$. For each $i \in [1, n - 1]$, split $S$ into substrings $A$ and $B$, while $A = S[1,i]$ and $B = S[i + 1, n]$. For all the string pairs formed by some non empty substring of $A$ and some non empty substrings of $B$, count the numbers of pairs satisfying $k-matching$.
 

Input
The first line contains an integer $T\ (T\leq 60)$, denoting the number of test cases.

For each test case, input two integers $n\ (2 \leq n\leq 3000)$ and $k\ (0 \leq k \leq 3000)$ for the first line.

The second line contains $n$ characters denoting the string $S$.

Guarantee that $S$ only contains lowercase letters and the sum of $n$ is no more than $20000$.
 

Output
For each test case, output $n - 1$ lines.

The $i$-th line contains only a integer denoting the number of the pairs for $i$.
 

Sample Input
3 4 0 jslj 6 1 abcazz 5 0 zzzzz
 

Sample Output
1 1 1 5 9 10 8 5 4 8 8 4
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-11 19:26:12, Gzip enabled