#P11210. 『STA - R8』强制在线动态二维数点

    ID: 12269 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>线段树二分2024洛谷原创O2优化Ad-hoc洛谷比赛

『STA - R8』强制在线动态二维数点

Background

The latest achievement in the data structure world. Forced online dynamic 2D point counting can already be done in linear time!

Problem Description

To win the Turing Award, you need to solve the following dynamic online 2D point counting problem.

There are nn points (xi,yi)(x_i, y_i) on the plane, arranged below the line y=x\bm{y=x} (that is, yixi\bm{y_i \le x_i} holds).

I will perform qq operations. There are two types of operations:

  1. Update operation U i x y: set xi:=x,yi:=yx_i := x, y_i := y. (That is, assign xx and yy to xix_i and yiy_i respectively.)
  2. Query operation Q l r: given a rectangle whose four vertices are (l,l),(r,l),(l,r),(r,r)\bm{(l,l),(r,l),(l,r),(r,r)}, find the minimum value of xyx-y among all points ^\dagger (x,y)(x, y) inside the given rectangle. In particular, if the rectangle contains no points, the answer is defined as 0\bm{0}.

The two types of operations will be encrypted in some way. See the detailed requirements in the [Input Format] section below.

^\dagger: A point (x,y)(x, y) is inside the rectangle formed by (l,l),(r,l),(l,r),(r,r)(l,l),(r,l),(l,r),(r,r) if and only if lxrl \le x \le r and lyrl \le y \le r.

Input Format

The first line contains two integers nn and qq.

The next nn lines each contain two integers xix_i and yiy_i, describing the coordinates of each point.

The following qq lines give the type of each operation and the encrypted values of its parameters. The true decrypted values of i,x,y,l,ri, x, y, l, r must all be XORed with your previous output answer (do not XOR before the first query operation). It is guaranteed that after decryption, the constraints 1lrn1 \le l \le r \le n and 1in1 \le i \le n, 1yxn1 \le y \le x \le n hold.

Output Format

For each query operation, output one line containing your answer.

5 6
4 1
4 1
4 2
4 1
5 2
Q 2 5
U 6 6 3
Q 3 7
Q 1 6
U 2 4 2
Q 2 3
2
2
0
0

Hint

For all testdata, 1n,q5×1051 \le n, q \le 5 \times 10^5, and it is guaranteed that after decryption, 1lrn1 \le l \le r \le n and 1in1 \le i \le n, 1yxn1 \le y \le x \le n.

This problem uses bundled tests and enables subtask dependencies.

  • Subtask 0 (5 points): n,q5×103n, q \le 5 \times 10^3.
  • Subtask 1 (20 points): no update operations.
  • Subtask 2 (25 points): satisfies special properties.
  • Subtask 3 (20 points): n,q105n, q \le 10^5.
  • Subtask 4 (30 points): no special restrictions.

Special properties (random data): the operation types, update positions, point coordinates (initial and after updates), and query ranges (the values of parameters (i,x,y),(l,r)(i,x,y),(l,r)) are generated independently and uniformly at random within the valid ranges.

Translated by ChatGPT 5