#P17286. 「IXOI R2」Horizon Blue

    ID: 19632 远端评测题 5000ms 512MiB 尝试: 0 已通过: 0 显示难度NOI/NOI+/CTS 上传者: 标签>洛谷原创O2优化洛谷月赛

「IXOI R2」Horizon Blue

Background

(The picture is from the Phigros song artwork. Please contact to remove if infringement.)

Problem Description

You are given a sequence aa of length nn, and mm operations. You must process the following two types of operations in a forced online manner.

  • 1 x y: increase the xx-th number in the sequence by yy.
  • 2 l r: compute the sum of the maximum values of all non-empty contiguous subsegments within the interval [l,r][l,r], and output the result modulo 2322^{32}.

It is guaranteed that all numbers in the sequence are pairwise distinct at any time.

Input Format

The first line contains two integers n,mn,m.

The second line contains nn integers a1,a2,…,ana_1,a_2,\ldots,a_n, representing the initial sequence.

The next mm lines each follow one of the two formats:

  • 1 x y.
  • 2 l r.

Let last be the actual output of the previous query. Initially, last = 0. All XOR operations are performed on unsigned 32-bit integers.

  • For an input operation 1 x y, the actual modified position is

    xreal=x⊕last.x_{\mathrm{real}}=x\oplus \mathrm{last}.

    The parameter yy is not XORed.

  • For an input operation 2 l r, the actual queried interval is

    $$[l_{\mathrm{real}},r_{\mathrm{real}}] =[l\oplus \mathrm{last},\ r\oplus \mathrm{last}].$$
  • Let the true answer of this query be SS. Output

    ans=S mod 232,\mathrm{ans}=S\bmod 2^{32},

    and set

    last←ans.\mathrm{last}\leftarrow \mathrm{ans}.

It is guaranteed that all operations are valid after decoding.

Output Format

For each operation of type 2, output one integer per line, representing the answer modulo 2322^{32}.

10 10
305 6197 2133 7051 30 8411 2622 2173 8522 2998
1 2 5734
2 2 10
1 368406 9714
2 368402 368407
1 64015 4680
2 64015 64003
1 152896 5381
1 152898 5974
1 152904 9158
1 152911 7250
368401
64011
152906

Hint

This problem uses bundled testdata.

Subtask n,m≤n,m\le Special Property Score
11 10410^4 None 1010
22 2×1052\times10^5 Yes 3030
33 10510^5 None 2020
44 1.5×1051.5\times10^5
55 2×1052\times10^5

Special Property: after decoding, all queries satisfy l=1,r=nl=1,r=n.

For all data, it is guaranteed that:

$$0\le a_i,y\le 10^9, 1\le x_{\mathrm{real}},l_{\mathrm{real}}\le r_{\mathrm{real}}\le n$$

and the encoded x,l,rx,l,r in the input are in [0,232−1][0,2^{32}-1].

It is guaranteed that at any time ai≤2×109a_i\le 2\times 10^9, and all numbers in the sequence are pairwise distinct.

Translated by ChatGPT 5