#P12389. Sequence Modulo Range Update and Subarray Equality
Sequence Modulo Range Update and Subarray Equality
Sequence Modulo Range Update and Subarray Equality
You are given three positive integers \(n\), \(k\) and \(q\), and a sequence \(a\) of length \(n\). You need to process \(q\) operations or queries on the sequence. There are two types of operations:
- Update:
1 l r c
— For every index \(i\) from \(l\) to \(r\) (inclusive), update \(a_i = (a_i+c) \bmod k\). - Query:
2 l_1 r_1 l_2 r_2
— Check whether the two subarrays \(a[l_1\cdots r_1]\) and \(a[l_2\cdots r_2]\) are equal. PrintYes
if they are equal, andNo
otherwise.
The operations are given in the order of input. Process each operation accordingly.
inputFormat
The first line contains three integers \(n\), \(k\) and \(q\). The second line contains \(n\) integers representing the sequence \(a_1, a_2, \ldots, a_n\). Each of the next \(q\) lines describes an operation in one of the two formats:
1 l r c
— update operation (add \(c\) modulo \(k\) to each element from index \(l\) to \(r\)).2 l1 r1 l2 r2
— query operation (check if subarray \(a[l1..r1]\) equals subarray \(a[l2..r2]\)).
outputFormat
For each query operation (type 2), output a single line containing either Yes
or No
indicating whether the two specified subarrays are equal.
sample
5 10 5
1 2 3 4 5
1 1 3 2
2 1 2 4 5
1 2 5 3
2 1 3 3 5
2 3 5 3 5
No
No
Yes
</p>