#P6019. Online Colored Sequence Queries
Online Colored Sequence Queries
Online Colored Sequence Queries
Given a sequence (a) of length (n) where each element has a color, and (m) operations, perform the following online operations:
-
Update Operation (Type 1): [ 1\ l\ r\ x ] Set all elements in the interval ([l, r]) to (x).
-
Query Operation (Type 2): [ 2\ l\ r ] Count the number of ordered pairs ((i,j)) with (l \le i < j \le r) such that (a_i = a_j).
Online Mechanism: For every operation, the parameters (l), (r) (and (x) for type 1) are first XORed with the previous query's answer (with the previous answer taken modulo (2^{32})). If there is no previous query, the previous answer is considered (0). Note that the output for a query is the full number (without taking modulo (2^{32})).
inputFormat
The first line contains two integers (n) and (m).\nThe second line contains (n) integers (a_1, a_2, \ldots, a_n) representing the initial sequence.\nEach of the following (m) lines represents an operation in one of the following formats:\n(1\ l\ r\ x) for an update operation, and (2\ l\ r) for a query operation.\nNote: For every operation, each parameter is given after applying a bitwise XOR with the previous query's answer (with the previous answer taken modulo (2^{32})).
outputFormat
For each query operation (type 2), output the corresponding result on a new line.
sample
5 5
1 2 3 4 5
2 1 5
1 2 4 2
2 1 5
1 7 6 10
2 1 6
0
3
2
</p>