문제
Note: The memory limit for this problem is 512MB, twice the default.
After years of hosting games and watching Bessie get first place over and over, Farmer John has realized that this can't be accidental. Instead, he concludes that Bessie must have winning coded into her DNA so he sets out to find this "winning" gene.
He devises a process to identify possible candidates for this "winning" gene. He takes Bessie's genome, which is a string of length where . He picks some pair where representing that the "winning" gene candidates will have length and will be found within a larger length substring. To identify the gene, he takes all length substrings from which we will call a -mer. For a given -mer, he takes all length substrings, identifies the lexicographically minimal substring as a winning gene candidate (choosing the leftmost such substring if there is a tie), and then writes down the -indexed position where that substring starts in to a set .
Since he hasn't picked and yet, he wants to know how many candidates there will be for every pair of .
For each in , help him determine the number of pairs with .
입력
representing the length of the string. representing the given string. All characters are guaranteed to be uppercase characters where since bovine genetics are far more advanced than ours.
출력
For each in , output the number of pairs with , with each number on a separate line.
예제 입력 1
8
AGTCAACG
예제 출력 1
11
10
5
4
2
2
1
1
점수
Inputs 2-4: Inputs 5-7: Inputs 8-16: No additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인