Under construction

Still being built. Things may change

String Algorithm

Time limit20sMemory limit512 MB

Summary
For every k, cut s into blocks of length k, discard the tail, and count block pairs whose Hamming distance is at most one.
Level

Hard9 of 10

Topics
String, Hash map, String matching, Divide and conquer
Solved
No attempts yet

Problem

We give you a string ss of length nn.

Fix some kk (1≤k≤n1 \le k \le n). Create m=⌊n/k⌋m = \lfloor n/k \rfloor strings of length kk, the ii-th of them being the substring of ss that starts at position (i−1)k+1(i-1)k+1: pi=s(i−1)k+1s(i−1)k+2…sikp_i = s_{(i-1)k+1} s_{(i-1)k+2} \dots s_{ik}.

In other words, cut the string ss into strings of length kk and discard the leftovers. Let f(k)=∣{(i,j)∣1≤i<j≤m,dist⁡(pi,pj)≤1}∣f(k) = |\{(i, j) \mid 1 \le i < j \le m, \operatorname{dist}(p_i, p_j) \le 1\}|, where dist⁡\operatorname{dist} is the Hamming distance. That is, f(k)f(k) is the number of pairs of strings pp that differ in at most one position.

Design an algorithm to compute f(k)f(k) for all kk from 1 to nn.

Input

The first line contains one positive integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5), the length of the string.

The second line contains the string ss of length nn, consisting of lowercase English characters.

Output

Print nn numbers, the kk-th of them being f(k)f(k).

Examples3

  1. Example 1

    Input
    7
    kkekeee
    
    Expected output
    21 2 1 0 0 0 0
    
  2. Example 2

    Input
    10
    babaiskeke
    
    Expected output
    45 2 0 0 0 0 0 0 0 0
    
  3. Example 3

    Input
    11
    aaabaaabaaa
    
    Expected output
    55 10 2 1 0 0 0 0 0 0 0