#P9491. ZHY 的集合
ZHY 的集合
Problem Description
The time limit was changed to 1 s after the contest.
ZHY once again misread the problem during the contest.
For two sets each of size , satisfying (the empty set), ZHY defines as follows:
-
Let . Sort the elements in in increasing order.
-
.
Now, ZHY has sets , each of size . He wants to know the value of $\displaystyle \sum_{i=1}^n\sum_{j=i + 1}^n f(S_i,S_j)$.
However, ZHY is not satisfied with this. So he performs modification operations. In each operation, one set is given again. After each modification, output the answer once, i.e., $\displaystyle \sum_{i=1}^n\sum_{j=i + 1}^n f(S_i,S_j)$. It is guaranteed that at any time, all elements within any set are pairwise distinct, and the intersection of any two sets is empty.
Input Format
The first line contains three integers .
Lines to each contain integers describing the sets . The numbers on line are the integers in set .
Then follow lines. In each line, the first integer is , indicating the index of the set to be modified. The following numbers are the integers in the new .
Output Format
The first line contains one integer, the initial answer.
Then output lines, each containing one integer, the answer after each modification.
3 2 2
1 3
2 6
4 8
1 3 5
2 7 9
13
18
26
Hint
This problem uses bundled testdata.
| Score | ||||
|---|---|---|---|---|
For all data, , , . It is guaranteed that at any time, for $\forall i\in [1,n],\kern{2pt}j \in [1,m],\kern{2pt}i' \in[1,n],\kern{2pt}j'\in [1,m]$, if or , then
Translated by ChatGPT 5