#P4585. [FJOI2015] 火星商店问题

    ID: 3505 远端评测题 2000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2015线段树各省省选福建分治可持久化

[FJOI2015] 火星商店问题

Description

On a commercial street on Mars, there are nn shops arranged in order by shop IDs 1n1 \sim n. Among the many goods sold in the shops, each item is priced with a non-negative integer val\text{val}. Each shop may bring in some new goods every day, and the price may be the same as existing goods.

When Martians shop on this street, they usually visit all shops along a certain segment of the street, for example, the shops with IDs in the interval [l,r][l,r], and choose their favorite item from them. Each Martian has different preferences.

Usually, each Martian has a personal preference code xx. For an item priced at val\text{val}, a Martian with preference code xx likes it in proportion to the value of val xor x\text{val xor }x. That is, the larger val xor x\text{val xor }x is, the more they like the item.

Each Martian’s shopping card can only be used to buy goods stocked within the most recent dd days (including the current day) across all shops. In addition, each shop has one special item that is not restricted by the stocking date, and each Martian can choose this special item at any time. The supply of every item in each shop is guaranteed; there is no out-of-stock issue.

Given events arranged in chronological order, for each shopping Martian, compute the item they like most in this shopping activity, i.e., output the maximum value of val xor x\text{val xor }x. The events in chronological order refer to the following two types:

0 s v, meaning that shop ss stocks a new item priced at vv on the current day.

1 l r x d, meaning that a Martian shops on the current day in shops with IDs in [l,r][l,r], buying items stocked within dd days, and this Martian’s preference code is xx.

Input Format

The first line contains two positive integers n,mn,m, representing the total number of shops and the total number of events.

The second line contains nn integers; the ii-th integer is the price of the special item in shop ii.

The next mm lines each describe one event. The events of each day are arranged in the order that event type 00 comes first, then event type 11.

Output Format

For each event of type 11, output one line with one integer representing the answer.

4 6
1 2 3 4
1 1 4 1 0
0 1 4
0 1 3
1 1 1 1 0
1 1 1 1 1
1 1 2 1 2
5
0
2
5

Hint

Constraints
For 100%100\% of the data, all input integers are in the range [0,105][0,10^5].

Translated by ChatGPT 5