#P4692. [Ynoi Easy Round 2016] 谁的梦
[Ynoi Easy Round 2016] 谁的梦
Description
You are playing a galgame when the power suddenly goes out. You run to the property management office to ask, and find out it was because a bald guy kicked the transformer, and it may take a long time to fix. So you decide to think about a data structure problem you saw before:
Define the weight of a sequence as the number of distinct numbers in it. For example, has weight .
Now there are sequences. For each sequence, we choose a non-empty contiguous substring, and concatenate them. Compute the sum of the weights of the resulting sequence over all choices.
If a sequence can be obtained in multiple ways, count it multiple times.
This problem includes modification operations; see the input format.
Since the result may be too large, output the answer .
Input Format
The first line contains two integers , meaning there are sequences and modifications.
The second line contains integers; the -th number is , meaning the length of the -th sequence.
Then follow lines; the -th line contains integers, representing the -th sequence.
Then follow lines; each line contains three integers , meaning change the -th element of the -th sequence to .
Output Format
Output lines, each containing one integer, representing the answer for the initial state and after each modification, in order.
2 5
6 6
1 3 1 1 3 2
2 3 3 2 1 1
1 1 1
1 1 2
1 1 2
1 1 1
1 1 1
1158
1158
1168
1168
1158
1158
Hint
Idea: nzhtl1477, Solution: nzhtl1477, Code: nzhtl1477, Data: nzhtl1477 ( partially uploaded )
. The elements in the sequences are all -bit integers, and .
There are test cases.
Translated by ChatGPT 5
京公网安备 11011102002149号