#P9785. [ROIR 2020] 对常规的斗争 (Day1)

[ROIR 2020] 对常规的斗争 (Day1)

Problem Description

Translated from ROIR 2020 Day1 T3. Борьба с рутиной , translator: ShineEternal.

An important factor in evaluating an employee's performance is the ability to handle routine tasks.

We consider an employee's work over consecutive nn days. The task performed on day ii is aia_i.

To evaluate the employee's performance, we use the following method:

Choose an integer dd and consider all consecutive segments of dd days. For each such segment, count the number of different types of tasks the employee completed.

Let SdS_d be the sum, over all such consecutive dd-day segments, of the number of distinct task types completed in that segment.

Now you need to compute S1nS_{1\sim n}.

Input Format

The input consists of two lines.

The first line contains an integer nn, representing the total number of working days.

The second line contains nn integers, representing the task type ID done each day.

Output Format

Output nn numbers, which are S1nS_{1\sim n}.

5
1 3 2 1 2
5 8 8 6 3
3
10 10 10
3 2 1

Hint

Sample 1 Explanation

  • S1S_1:
Segment All task types Number of distinct task types
111-1 11 11
222-2 33
333-3 22
444-4 11
555-5 22

So S1=1+1+1+1+1=5S_1=1+1+1+1+1=5.

  • S2S_2:
Segment All task types Number of distinct task types
121-2 1,31,3 22
232-3 3,23,2
343-4 2,12,1
454-5 1,21,2

So S2=2+2+2+2=8S_2=2+2+2+2=8.

  • S3S_3:
Segment All task types Number of distinct task types
131-3 1,3,21,3,2 33
242-4 3,2,13,2,1
353-5 2,1,22,1,2 22

So S3=3+3+2=8S_3=3+3+2=8.

  • S4S_4:
Segment All task types Number of distinct task types
141-4 1,3,2,11,3,2,1 33
252-5 3,2,1,23,2,1,2

So S4=3+3=6S_4=3+3=6.

  • S5S_5:
Segment All task types Number of distinct task types
151-5 1,3,2,1,21,3,2,1,2 33

So S5=3S_5=3.

Constraints

For 100%100\% of the testdata, 1n2×1051\leq n\leq 2\times 10^5, 1ai1091\leq a_i\leq 10^9.

Subtask ID Special Constraints Score
11 1n50,1ai501\leq n \leq 50, 1 \leq a_i \leq 50 1212
22 1n50,1ai1091\leq n \leq 50, 1 \leq a_i \leq 10^9 1010
33 1n500,1ai1091\leq n \leq 500, 1 \leq a_i \leq 10^9
44 1n5000,1ai50001\leq n \leq 5000, 1 \leq a_i \leq 5000 1212
55 1n5000,1ai1091\leq n \leq 5000, 1 \leq a_i \leq 10^9 1010
66 1n2×105,1ai501\leq n \leq 2\times 10^5, 1 \leq a_i \leq 50 1616
77 No special constraints 3030

Translated by ChatGPT 5