#P12179. DerrickLo's Game (UBC002B)

DerrickLo's Game (UBC002B)

Description

There is an array aa with nn numbers (1n,ai2×1051\le n,a_i\le 2\times10^5). You have to handle qq modifications or queries (1q2×1051\le q\le 2\times10^5). There are two types of modifications or queries:

  • Input 1 k x, this changes aka_k into xx (1kn1\le k\le n, 1x2×1051\le x\le 2\times10^5) (modify).

  • Input 2 l r, you have to print the minimum cost of making alara_l\dots a_r the same by the two operations below (This does not really changes the array.) (1lr2×1051\le l\le r\le 2\times 10^5) (query):

  1. Choose an integer pp, increase apa_p by 11. This costs 11.

  2. Choose an interval [x,y][x,y], change axaya_x\dots a_y into maxi=xyai\max\limits_{i=x}^ya_i. This costs (yx+1)2(y-x+1)^2.

Input Format

The first line contains two integers n,qn,q.

The second line contains nn integers, representing aa.

For the next qq lines, each line contains three integers, representing a modify or a query.

Output Format

Suppose there are tt queries. Please output tt lines, representing the answers for each one.

3 2
1 2 3
2 1 2
2 1 1
1
0

Hint

For the first query, we choose a1a_1 and increase it by 11. This costs 11. So output 11.

For the second query, we don't need to do any operations since the number in [1,1][1,1] is already the same.