#P9061. Point Updates and Range Queries
Point Updates and Range Queries
Point Updates and Range Queries
You are given n points \((x_i, y_i)_{i=1}^n\). You are then required to process m operations sequentially. Each operation is given as five integers \(o, x, y, X, Y\) and works as follows:
- Update step:
- If \(o = 1\), for each point \((x_i, y_i)\) such that \(x_i \le x\) and \(y_i \le y\), update \(y_i\) to \(y\) (i.e. set \(y_i = y\)).
- If \(o = 2\), for each point \((x_i, y_i)\) such that \(x_i \le x\) and \(y_i \le y\), update \(x_i\) to \(x\) (i.e. set \(x_i = x\)).
- Query step: Count and output the number of points that satisfy \(x_i \le X\) and \(y_i \le Y\).
The operations affect the points cumulatively.
inputFormat
The first line contains two integers \(n\) and \(m\) representing the number of points and the number of operations respectively.
The next \(n\) lines each contain two integers \(x_i\) and \(y_i\), representing the initial coordinates of each point.
The following \(m\) lines each contain five integers \(o, x, y, X, Y\) describing an operation.
outputFormat
For each of the \(m\) operations, output a single line containing one integer, the number of points satisfying \(x_i \le X\) and \(y_i \le Y\) after the update.
sample
3 3
1 2
3 1
2 4
1 2 3 3 4
2 3 2 3 3
1 2 5 3 10
3
2
3
</p>