#683
Unrated
The 'Winning' Gene
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

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 SS of length NN where 1N30001 \leq N \leq 3000. He picks some pair (K,L)(K,L) where 1LKN1 \leq L \leq K \leq N representing that the "winning" gene candidates will have length LL and will be found within a larger KK length substring. To identify the gene, he takes all KK length substrings from SS which we will call a kk-mer. For a given kk-mer, he takes all length LL 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 00-indexed position pip_i where that substring starts in SS to a set PP.

Since he hasn't picked KK and LL yet, he wants to know how many candidates there will be for every pair of (K,L)(K,L).

For each vv in 1N1\dots N, help him determine the number of (K,L)(K,L) pairs with P=v|P|=v.

입력

NN representing the length of the string. SS representing the given string. All characters are guaranteed to be uppercase characters where siAZs_i \in A-Z since bovine genetics are far more advanced than ours.

출력

For each vv in 1N1\dots N, output the number of (K,L)(K,L) pairs with P=v|P|=v, with each number on a separate line.

예제 입력 1

8
AGTCAACG

예제 출력 1

11
10
5
4
2
2
1
1

점수

Inputs 2-4: N100N \leq 100 Inputs 5-7: N500N \leq 500 Inputs 8-16: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.