#P12389. COmPoUNdS

COmPoUNdS

Background

For some reason, Little S is especially fond of range add and range modulo. He created some problems like this, but basically could not solve any of them. One day, Little S accidentally drank a bit of iced black tea and suddenly got inspired, instantly solving all the problems. Taking advantage of the effect, he randomly picked one problem and generated the testdata. However, after the effect wore off, he no longer knew how to solve it. So please help him write a standard solution. If you succeed, he will give you a bottle of iced black tea.

Problem Description

Given positive integers n,k,qn, k, q and a sequence aa of length nn, there are qq operations or queries:

  • 1 l r c: For every i[l,r]i \in [l, r], set ai(ai+c)modka_i \gets (a_i + c) \bmod k.
  • 2 l1 r1 l2 r2: Determine whether two subsegments of aa with the same length, al1r1a_{l_1 \cdots r_1} and al2r2a_{l_2 \cdots r_2}, are equal.

Input Format

The first line contains three positive integers n,k,qn, k, q.

The second line contains nn positive integers representing the initial values of the sequence aa.

The next qq lines each describe an operation or query. The format is given in the description.

Output Format

Output several lines, one for each operation of type 2. If they are equal, output Yes; otherwise output No.

6 3 6
0 1 2 0 1 2
2 1 2 1 2
2 1 2 4 5
2 1 2 5 6
1 1 2 1
2 1 2 4 5
2 1 2 5 6
Yes
Yes
No
No
Yes

Hint

This problem uses bundled tests and subtask dependencies.

Subtask ID Score Special Restriction Dependent Subtasks Time Limit
11 1010 n,q103n, q \le 10^3 1.5 s\text{1.5 s}
22 2020 k=2k = 2 2.5 s\text{2.5 s}
33 n105n \le 10^5 11 1.5 s\text{1.5 s}
44 5050 No special restriction 1,2,31, 2, 3 2.5 s\text{2.5 s}

For all testdata, 1n,q1061 \le n, q \le 10^6, 2k1062 \le k \le 10^6, 0ai,c<k0 \le a_i, c < k. For operations of type 2, r1l1=r2l2r_1 - l_1 = r_2 - l_2.

Translated by ChatGPT 5