ADACLEAN - Ada and Spring Cleaning
Ada the Ladybug has decided to do some "Spring Cleaning". As you might know, she keeps a TODO list. She is very sparing so she keeps all her activities as one string. You might get very confused while reading the string but she has a system - every activity has length exactly K characters. Sadly, as new activities were added to the list many duplicities appeared. Now it is time to find out how many unique activities are in her TODO list.
First line contains T, number of test-cases.
Each test-case begins with N, K, 1 ≤ K ≤ N ≤ 105, length of string and length of activites respectively.
Next line consists of string of length N, consisting of lowercase letters.
The sum of lengths of strings among all test-cases won't exceed 3*105
For each test-case, print the number of unique substrings of length K
5 3 2 aaa 5 1 abcba 4 2 abac 10 2 abbaaaabba 7 3 dogodog
1 3 3 4 4
I am getting WA on 13 .I used only one hash function.!!
@Morass Nice ProblemLast edit: 2019-08-15 01:12:26
how to do this question i am not able to do
@Morass Good application.
You can use more than 1 hash function to make it stronger and avoid WA. I used two hash functions:
. If the hashes are equal (hash(s)=hash(t)), then the strings do not necessarily have to be equal.Keep This in mind Good Luck.
AC in 1 go ezz segment tree
if this problem quite hard, you can check out the hint: https://spoj-solution.github.io/2019/03/31/ADACLEAN.html
Can you please check 21232915. It exceeds time limit. Maybe some problem with hash function. I self reviewed many times, cant find mistake.