#P9057. [Ynoi2004] rpfrdtzls

[Ynoi2004] rpfrdtzls

Problem Description

Given n,m,An, m, A, maintain a sequence of sequences a1,,ana_1, \dots, a_n. Initially, each aia_i contains one element A+1A + 1.

There are mm operations in total:

  • Modification: given l,r,xl, r, x, for all lirl \le i \le r, insert the element xx to the front of sequence aia_i.
  • Query: given l,rl, r, query i=lrF(ai,A)\sum\limits_{i=l}^r F(a_i, A).

Where F((x1,,xn),0)=0F((x_1, \dots, x_n), 0) = 0.

For k>0k > 0, $F((x_1, \dots, x_n), k) = F((x_2, \dots, x_n), \lfloor \frac{k}{x_1} \rfloor) + 1$.

Input Format

The first line contains three integers n,m,An, m, A.

The next mm lines each describe an operation: 1,l,r,x1, l, r, x denotes a modification operation, and 2,l,r2, l, r denotes a query operation.

Output Format

For each query operation, output one line containing the answer.

5 20 10
1 4 4 166348285
2 2 5
2 1 5
1 1 2 10
1 4 4 3
1 4 5 6
2 5 5
1 5 5 1
1 2 3 1
2 5 5
2 5 5
2 3 4
2 3 3
2 4 5
2 4 4
1 2 5 5
1 5 5 9
1 1 4 5
2 5 5
2 1 4
4
5
2
3
3
4
2
5
2
2
8

Hint

Idea: nzhtl1477, Solution: ccz181078, Code: ccz181078, Data: ccz181078.

Constraints: for 100%100\% of the testdata, 1n,m5×1051 \le n, m \le 5 \times 10^5, 1A,x1091 \le A, x \le 10^9, and 1lrn1 \le l \le r \le n.

For 25%25\% of the testdata, n,m100n, m \le 100.

For 50%50\% of the testdata, n,m105n, m \le 10^5.

For another 25%25\% of the testdata, x1x \ne 1.

For the remaining 25%25\% of the testdata, there are no special restrictions.

Translated by ChatGPT 5