#P8582. [CoE R5] 斑马王子

    ID: 9385 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>线段树洛谷原创O2优化字典树 Trie位运算洛谷月赛

[CoE R5] 斑马王子

Background

Note: In Subtask #4 of this problem, opti=3opt_i=3 can be treated as opti=0opt_i=0. The testdata will be fixed later, and another notice will be given after the fix.

UPD: Fixed.

Problem Description

Brief statement

There is an array ss of length k+1k+1, indexed from 00 to kk. Initially, si=0 (0ik)s_i = 0 \ (0 \leqslant i \leqslant k).

Next, you are given nn pairs of non-negative integers (li, ri)(l_i,\ r_i). Let T=i=1n[li, ri]T = \bigcup\limits_{i = 1}^n [l_i,\ r_i]. Set all sis_i with iTZi \in T \bigcap \mathbb{Z} to 11.

At any moment, define $S =\{ x \mid x \in \mathbb{Z} \wedge x \in [0,\ k] \wedge s_x = 0 \}$. Then you are given mm triples of non-negative integers (opti, ai, bi)(opt_i,\ a_i,\ b_i).

  • When opti=0opt_i = 0, compute:
$$t_i = \sum\limits_{x = a_i}^{b_i} \min\limits_{y \in S}(x \oplus y)$$
  • When opti=1opt_i = 1, set all sis_i with i[ai, bi]Zi \in [a_i,\ b_i] \bigcap \mathbb{Z} to 11.

  • When opti=2opt_i = 2, set all sis_i with i[ai, bi]Zi \in [a_i,\ b_i] \bigcap \mathbb{Z} to 00.

Here, Z\mathbb{Z} denotes the set of all integers, and \oplus denotes XOR.


Original story statement

The “Zebra Prince” rules over the boundless grassland.

A small river flows quietly through the center of the grassland. A piece of grassland at distance yy from the river source is given “membrane power” (mo li, 膜力) of value y (0yk)y \ (0 \leqslant y \leqslant k).

On day x (0xk)x \ (0 \leqslant x \leqslant k), the Zebra Prince’s “potential IQ” is xx.

He will go to a grassland he likes to dine, and start a new day with “IQ” equal to xyx \oplus y.

There is a kind of creature called “hunters”, who love to take away the lives of grassland residents.

Initially, they set up nn camps of the form $(l_i,\ r_i) \ (0 \leqslant l_i \leqslant r_i \leqslant k)$, and use “guns” to kill all living beings that stop within [li, ri][l_i,\ r_i].

As the Zebra Prince’s capable minister, you need to answer some of his questions to keep the grassland safe.

On this ever-changing grassland, mm events of the form $(opt_i,\ a_i,\ b_i) \ (0 \leqslant a_i \leqslant b_i \leqslant k , \ opt_i \in \{0,\ 1,\ 2\})$ will happen in order.

When opti=1opt_i = 1, event ii means the hunters have set up new camps everywhere in [ai, bi][a_i,\ b_i].

When opti=2opt_i = 2, event ii means the Zebra Prince’s brave army has destroyed all camps in [ai, bi][a_i,\ b_i].

When opti=0opt_i = 0, the Zebra Prince asks you a soul-searching question:

In each query, from day aia_i to day bib_i (0aibik)(0 \leqslant a_i \leqslant b_i \leqslant k), the Zebra Prince wants to dine on grasslands that are not “hunter” camps. He wants to know the minimum possible value tit_i of the sum of “IQ” from day aia_i to day bib_i.

You rack your brain. Suddenly, the roar of “guns” tears the air apart. If you cannot answer within 1 sec1 \ sec

Input Format

The first line contains integers n, m, kn, \ m, \ k.

The next nn lines each contain two integers li, ril_i, \ r_i, describing one hunter camp.

The next mm lines each contain three integers opti, ai, biopt_i,\ a_i,\ b_i, describing one operation.

Output Format

For the ii-th operation (1im)(1 \leqslant i \leqslant m):

  • If opti=1opt_i = 1 or opti=2opt_i = 2, you do not need to output anything.
  • If opti=0opt_i = 0, then if all grasslands belong to hunter camps, output one line Death. Otherwise, output one line with an integer, representing tit_i.
0 16 3
0 0 3
1 3 3
0 0 3
1 1 2
0 0 3
2 1 3
0 0 3
1 0 0
1 1 1
0 0 3
0 1 2
0 1 3
1 2 3
0 2 3
2 3 3
0 2 3
0
1
6
0
4
2
2
Death
1

Hint

Constraints

This problem uses bundled tests.

Subtask 1 (5 pts)\texttt{Subtask 1 (5 pts)}: For 5%5\% of the data, 0n,m,k200 \leqslant n,m,k \leqslant 20.

Subtask 2 (5 pts)\texttt{Subtask 2 (5 pts)}: For 5%5\% of the data, 0n,m,k5000 \leqslant n,m,k \leqslant 500.

Subtask 3 (15 pts)\texttt{Subtask 3 (15 pts)}: For 15%15\% of the data, 0n,m,k40000 \leqslant n,m,k \leqslant 4000.

Subtask 4 (5 pts)\texttt{Subtask 4 (5 pts)}: For 5%5\% of the data, opti=0opt_i = 0.

Subtask 5 (70 pts)\texttt{Subtask 5 (70 pts)}: No special restrictions.

For 100%100\% of the data: 0n, m, k2×1050 \leqslant n,\ m,\ k \leqslant 2 \times 10^5, 0lirik0 \leqslant l_i \leqslant r_i \leqslant k, 0aibik0 \leqslant a_i \leqslant b_i \leqslant k, and opti{0, 1, 2}opt_i \in \{0,\ 1,\ 2\}.

Translated by ChatGPT 5