#ABC285B. [ABC285B] Longest Uncommon Prefix

[ABC285B] Longest Uncommon Prefix

提示:该题测试数据补录中,暂不支持评测提交。

No testdata at current.

No submission language available for this problem.

Score : 200200 points

Problem Statement

You are given a string SS of length NN consisting of lowercase English letters. The xx-th (1≤x≤N)(1 \le x \le N) character of SS is SxS_x.

For each i=1,2,…,N−1i=1,2,\dots,N-1, find the maximum non-negative integer ll that satisfies all of the following conditions:

  • l+i≤Nl+i \le N, and
  • for all integers kk such that 1≤k≤l1 \le k \le l, it holds that Sk≠Sk+iS_{k} \neq S_{k+i}.

Note that l=0l=0 always satisfies the conditions.

Constraints

  • NN is an integer such that 2≤N≤50002 \le N \le 5000.
  • SS is a string of length NN consisting of lowercase English letters.

Input

The input is given from Standard Input in the following format:

NN

SS

Output

Print (N−1)(N-1) lines. The xx-th (1≤x<N)(1 \le x < N) line should contain the answer as an integer when i=xi=x.

6
abcbac
5
1
2
0
1

In this input, S=S= abcbac.

  • When i=1i=1, we have S1≠S2,S2≠S3,…S_1 \neq S_2, S_2 \neq S_3, \dots, and S5≠S6S_5 \neq S_6, so the maximum value is l=5l=5.
  • When i=2i=2, we have S1≠S3S_1 \neq S_3 but S2=S4S_2 = S_4, so the maximum value is l=1l=1.
  • When i=3i=3, we have S1≠S4S_1 \neq S_4 and S2≠S5S_2 \neq S_5 but S3=S6S_3 = S_6, so the maximum value is l=2l=2.
  • When i=4i=4, we have S1=S5S_1 = S_5, so the maximum value is l=0l=0.
  • When i=5i=5, we have S1≠S6S_1 \neq S_6, so the maximum value is l=1l=1.