#P5873. Points and Rectangles Pair Counting

    ID: 19101 Type: Default 1000ms 256MiB

Points and Rectangles Pair Counting

Points and Rectangles Pair Counting

You are given an initially empty 2D plane. You need to process \(q\) queries. There are two types of queries:

  • 1 x y — Add a point at coordinate \((x,y)\).
  • 2 x_1 y_1 x_2 y_2 — Add a rectangle with the bottom‐left corner at \((x_1,y_1)\) and the top‐right corner at \((x_2,y_2)\). The rectangle's area may be \(0\) and it can degenerate to a point.

Note that points and rectangles may overlap. After each query, you are required to compute the total number of \( (\text{point}, \text{rectangle})\) pairs such that the point lies inside or on the boundary of the rectangle.

Note: A point \((x,y)\) is inside a rectangle defined by \((x_1,y_1)\) and \((x_2,y_2)\) if and only if \(x_1 \le x \le x_2\) and \(y_1 \le y \le y_2\).

inputFormat

The first line contains an integer \(q\) representing the number of queries. Each of the following \(q\) lines contains a query in one of the formats described above.

outputFormat

For each query, output a single line containing the total number of valid \((\text{point}, \text{rectangle})\) pairs after processing that query.

sample

3
1 0 0
2 -1 -1 1 1
1 2 2
0

1 1

</p>