bzoj 3065

3065: inserting interval with a small value K

Time Limit: 60 Sec  Memory Limit: 512 MB
Submit: 5067  Solved: 1658
[Submit][Status][Discuss]

Description

Once there n fleas aligned morning exercise, each has its own flea a jumping force a [i]. The king looked at these flea flea thriving country scene, very happy. Then flea King rational decisions about pleasure, the query interval k small value. Every time he asked the question to its followers volts: from left to right x-th to the y-th flea in, a [i] small value of k is.
This can not beat volts, he uses in his head functional segment tree prefix and the method of water fleas off asking the king.
Then volt found some fleas jump long jumping ability will vary, some increases and some decreases.
This can not beat volts, he used Fenwick tree cover tree line in the water off the head method flea ask the king. (Orz Chairman of the tree)
then found some late volts fleas is inserted into a certain position on the line, he was very angry, because ...... he will not do so.
Please help a bunch volt bar.
Express Edition meaning of the questions: with insert, update interval k small value online inquiries.

 

Input

The first line of a positive integer n, n fleas indicates that there are arranged in a row do morning exercises.
The second row has n space-separated non-negative integer, from left to right on behalf of each jumping ability of fleas.
The third row a positive integer q, the following represents the number of operations.
A total of q rows following, the operation of a total of three operations prosequence :( assuming a total of m fleas)
1. XYK Q: From left to right the first interrogation fleas x to y fleas from left to right in the first, bouncing small flea jumping ability of the k-force is.
    (. 1 <= x <= Y <= m,. 1 <= K <= Y -. 1 + x)
2. x M Val: from left to right, jumping ability of fleas to x-val.
    (. 1 <= x <= m)
3. the I x val: from left to right in front of the x fleas insertion force of a jumping flea val. That is, after I insert the newly inserted fleas from left to right, the first x fleas Yes.
    (1 <= x <= m + 1)

In order to reflect the online operation, set lastAns to the results of a query when the output of the program, if you have not inquired, the lastAns = 0.
When the input is actually:
Q _K the _x _y ------> represents ^ lastAns the _x _y ^ Q lastAns _K ^ lastAns
M ------ _Val the _x> represents the _x ^ lastAns _Val ^ M lastAns
the I _Val the _x ------> represents I _x ^ lastAns _val ^ lastAns
is simply an integer of operation input to be exclusive or a query result is decoded.

(I wish the students a speedy transfer of Pascal C ++, pascal version does not provide a description.)

 

Output

For each query output to answer, one per line answer.

 

Sample Input

10
10 5 8 28 0 19 2 31 1 22
30
I 6 9
M 1 11
I 8 17
M 1 31
M 6 26
Q 2 7 6
I 23 30
M 31 7
I 22 27
M 26 18
Q 26 17 31
I 5 2
I 18 13
Q 3 3 3
I 27 19
Q 23 23 30
Q 5 13 5
I 3 0
M 15 27
Q 0 28 13
Q 3 29 11
M 2 8
Q 12 5 7
I 30 19
M 11 19
Q 17 8 29
M 29 4
Q 3 0 12
I 7 18
M 29 27

Sample Output

28
2
31
0
14
15
14
27
15
14

HINT

 

As this question a little research to carry out his practices have a lot of it ~ ~ I do not know how many questions a practice.

Please consciously O (log ^ 2n), I deliberately block the card list, a block chain A Please accept my affectionate thanks ......

A students out there please Discuss briefly say that under their own practices it -

the original sequence length <= 35,000

insert number <= 35000, the number of modifications <= 70000, the number of queries <= 70,000, 0 <= every moment weights <= 70,000

because it is the question OJ, so the data isocratic. To prevent card OJ, this question only four sets of data.

This problem is common practice in two ways: one is the block, another set of weights is scapegoat tree tree segments (segment tree merge operation is required) 

Guess you like

Origin www.cnblogs.com/ZJXXCN/p/11374585.html