#P16575. 古神线段树·改

    ID: 18765 远端评测题 3500ms 512MiB 尝试: 0 已通过: 0 显示难度NOI/NOI+/CTS 上传者: 标签>计算几何四川平衡树凸包2026类欧几里得算法

古神线段树·改

Background

The Ancient God Segment Tree is too hard, and the problem setter could not solve it, so they modified it.

Problem Description

  • A line is represented as (sx,sy,tx,ty)(sx, sy, tx, ty), and it is guaranteed that sxtxsx \not= tx.
  • When a line appears, it lights up all integer points (x,y)(x, y) that satisfy:$$y \cdot (tx-sx) \cdot \big( (ty-sy)\cdot(x-sx) - (tx-sx)\cdot(y-sy) \big) \ge 0$$
  • A point that has already been lit will not be turned off, and will not be lit a second time.

There are nn operations. An operation can be:

  1. Add a line.
  2. Query the number of lit points in a rectangular region.

Each test point contains multiple groups of testdata.

Input Format

The first line contains two positive integers c,Tc, T, representing the test point ID and the number of testdata groups. In the sample, cc is the smallest test point ID that satisfies the corresponding property.

For each group of testdata:

  • The first line contains one positive integer nn, representing the number of operations.

  • The next nn lines each contain 55 integers, describing an operation as follows:

    • 1 sx sy tx ty: add a line.
    • 2 lx ly rx ry: query the number of lit points satisfying lxxrxlx{\le}x{\le}rx and lyyryly{\le}y{\le}ry.

Output Format

For each operation 22, output one number per line as the answer.

1 1
3
1 1 2 4 1
1 4 4 2 1
2 1 1 4 3

8

Hint

The input size of this problem is large. A fast input template is provided in the downloadable files.

For all data:

  • 1n1×1061 \le n \le 1\times 10^6.
  • 1n2×1061 \le \sum n \le 2\times 10^6.
  • 109sx,sy,tx,ty109-10^9 \le sx, sy, tx, ty \le 10^9, and sxtxsx \not= tx.
  • 109lxrx109-10^9 \le lx \le rx \le 10^9, 109lyry109-10^9 \le ly \le ry \le 10^9.

::cute-table{tuack}

Test Point ID nn \leq n \sum n \leq Special Property
11 100100 500500 A
22 1×1061\times 10^6 2×1062\times 10^6 B
33 ^ C
44 D
55 1×1051\times 10^5 3×1053\times 10^5 None
6106\sim 10 1×1061\times 10^6 2×1062\times 10^6 ^
  • Special Property A: It is guaranteed that $\lvert lx \rvert, \lvert rx \rvert, \lvert ly \rvert, \lvert ry \rvert \le 500$.
  • Special Property B: It is guaranteed that lx=rxlx = rx.
  • Special Property C: It is guaranteed that sx=0,sy=0sx = 0, sy = 0.
  • Special Property D: It is guaranteed that ly=1e9,ry=1e9ly = -1e9, ry = 1e9.

Translated by ChatGPT 5