QOJ.ac

QOJ

Time Limit: 6 s Memory Limit: 512 MB Total points: 100

#8949. Heluaisa

统计

Given $n$ points $(x_i, y_i)_{i=1}^n$, you need to process $m$ operations in order. Each operation provides $o, x, y, X, Y$:

  • First, perform a modification:
    • If $o=1$, update $y_i$ to $y$ for all points satisfying $x_i \le x$ and $y_i \le y$.
    • If $o=2$, update $x_i$ to $x$ for all points satisfying $x_i \le x$ and $y_i \le y$.
  • Then, perform a query: count the number of points satisfying $x_i \le X$ and $y_i \le Y$.

Input

The first line contains two integers $n$ and $m$.

The next $n$ lines each contain two integers $x_i, y_i$.

The next $m$ lines each contain five integers $o, x, y, X, Y$, representing an operation.

Output

Output $m$ lines, each containing an integer representing the answer to the query for each operation.

Examples

Input 1

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

Output 1

4
3
0
0
0
0

Subtasks

For all data, $1 \le n, m \le 10^6$, $1 \le x_i, y_i, x, y, X, Y \le n$.

Subtask 1 (10 points): $n, m \le 10^3$.

Subtask 2 (20 points): $x_i, y_i, x, y, X, Y$ are chosen uniformly and independently at random from $1$ to $n$.

Subtask 3 (20 points): $o=1$.

Subtask 4 (20 points): $n, m \le 3 \times 10^5$, depends on Subtask 1.

Subtask 5 (30 points): No special restrictions, depends on Subtasks 1, 2, 3, and 4.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.