#P4070. [SDOI2016] 生成魔咒

    ID: 2977 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>字符串2016各省省选平衡树山东后缀自动机,SAM后缀数组,SA

[SDOI2016] 生成魔咒

Description

A spell string consists of many spell characters, and a spell character can be represented by a number. For example, we can piece together spell characters 1,21,2 to form a spell string [1,2][1,2].

A non-empty substring of a spell string SS is called a generating spell of SS.

For example, when S=[1,2,1]S = [1,2,1], its generating spells are [1],[2],[1,2],[2,1],[1,2,1][1],[2],[1,2],[2,1],[1,2,1], five in total. When S=[1,1,1]S = [1,1,1], its generating spells are [1],[1,1],[1,1,1][1],[1,1],[1,1,1], three in total. Initially, SS is an empty string.

There are nn operations in total. In each operation, one spell character is appended to the end of SS. After each operation, you need to determine how many distinct generating spells the current spell string SS has.

Input Format

The first line contains an integer nn.

The second line contains nn numbers. The ii-th number denotes the spell character xix_i appended in the ii-th operation.

Output Format

Output nn lines, one number per line.
The number on the ii-th line denotes the number of distinct generating spells after the ii-th operation.

7
1 2 3 3 3 1 2
1
3
6
9
12
17
22

Hint

Constraints
For 10% of the testdata, it is guaranteed that 1n101 \le n \le 10.
For 30% of the testdata, it is guaranteed that 1n1001 \le n \le 100.
For 60% of the testdata, it is guaranteed that 1n1031 \le n \le 10^3.
For 100% of the testdata, it is guaranteed that 1n1051 \le n \le 10^5, 1xi1091 \leq x_i \leq 10^9.

Translated by ChatGPT 5