Fish 2

아직 제출이 없습니다시간 제한4초메모리 제한1024 MB

문제

JOI-kun has NN fishes, numbered from 11 to NN. The size of the fish ii (1iN1 ≤ i ≤ N) is A_iA\_i.

When we grow fish, we have to pay attention to the following fact: if we have two nearby fishes, one fish eats the other fish as time passes. Here, two fishes are nearby if there is no fish between them. More precisely, if the size of the fish xx is larger than or equal to the size of the fish yy, and the fish xx and the fish yy are nearby, then the fish xx eats the fish yy, and the size of xx becomes the sum of the original size of xx and the size of yy. If the fish xx and the fish yy have the same size, any one of them may eat the other.

JOI-kun will grow fishes for QQ days. To kill time, he does the following thought experiment. On the jj-th day (1jQ1 ≤ j ≤ Q), JOI-kun takes one of the following actions.

  • Type 1 : JOI-kun gives a special feed to the fish X_jX\_j. After that, the size of the fish X_jX\_j becomes Y_jY\_j.
  • Type 2 : JOI-kun takes only the fishes whose indices are between L_jL\_j and R_jR\_j, inclusive. Then JOI-kun performs the following thought experiment: JOI-kun puts the fishes L_jL\_j, L_j+1L\_j + 1, \dots, R_jR\_j into an aquarium from left to right. By the above properties of the fishes, only one fish will survive in the aquarium. The index of the surviving fish depends on the choice of eaten fishes and the time when a fish eats another fish. JOI-kun wants to know the number of possible indices of surviving fishes. During the thought experiment, the order of the fishes does not change, and no two fishes eat the same fish simultaneously.

Write a program which, given information of JOI-kun’s fishes and JOI-kun’s plan, calculates the number of possible indices of surviving fishes for each action of Type 2 in order to determine whether JOI-kun’s thought is correct or not. Note that this is just a thought experiment. Please be assured that no fishes are eaten actually.

입력

Read the following data from the standard input. Given values are all integers.

\begin{align\*}& N \\\ & A\_1 \\, A\_2 \\, \cdots \\, A\_N \\\ & Q \\\ & \text{(Query }1\text{)} \\\ & \text{(Query }2\text{)} \\\ & \vdots \\\ & \text{(Query }Q\text{)}  \end{align\*}

Each (Query j)\text{(Query }j\text{)} (1jQ1 ≤ j ≤ Q) consists of space separated integers. Let T_jT\_j be the first integer of (Query j)\text{(Query }j\text{)}. The content of this line is one of the following.

  • If T_j=1T\_j = 1, this line contains two more space separated integers X_jX\_j, Y_jY\_j, in this order. This means JOI-kun takes an action of Type 1 on jj-th day. The size of the fish X_jX\_j becomes Y_jY\_j.
  • If T_j=2T\_j = 2, this line contains two more space separated integers L_jL\_j, R_jR\_j, in this order. This means JOI-kun takes an action of Type 2 on jj-th day. JOI-kun performs a thought experiment for fishes whose indices are between L_jL\_j and R_jR\_j, inclusive.

출력

For each action of Type 2 (i.e., for each jj (1jQ1 ≤ j ≤ Q) with T_j=2T\_j = 2), in order, write the number of possible indices of surviving fishes to the standard output. The outputs should be separated by line breaks.

제한

  • 1N100,0001 ≤ N ≤ 100\\,000.
  • 1Q100,0001 ≤ Q ≤ 100\\,000.
  • 1A_i1,000,000,0001 ≤ A\_i ≤ 1\\,000\\,000\\,000 (=109= 10^9) (1iN1 ≤ i ≤ N).
  • T_jT\_j is either 11 or 22 (1jQ1 ≤ j ≤ Q).
  • 1X_jN1 ≤ X\_j ≤ N (1jQ1 ≤ j ≤ Q).
  • 1Y_j1,000,000,0001 ≤ Y\_j ≤ 1\\,000\\,000\\,000 (=109= 10^9) (1jQ1 ≤ j ≤ Q).
  • 1L_jR_jN1 ≤ L\_j ≤ R\_j ≤ N (1jQ1 ≤ j ≤ Q).