#P17126. [ICPC 2025 Shanghai R] Flower' s land 4

    ID: 19463 远端评测题 2000ms 2048MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>二分2025上海凸包ICPC

[ICPC 2025 Shanghai R] Flower' s land 4

Problem Description

There are nn segments on a 2D2D plane. Each segment starts on the non-negative part of the xx-axis and ends on the non-negative part of the yy-axis. In other words, its starting point has coordinates (xi,0)(x_i, 0) with xi0x_i \ge 0, and its ending point has coordinates (0,yi)(0, y_i) with yi0y_i \ge 0.

You are given qq queries. In each query, a segment is specified whose starting point lies on the xx-axis, and whose ending point can be anywhere in the first quadrant or the non-negative parts of the axes of the plane. For each query segment, determine whether it intersects with any of the existing segments. Intersections at endpoints are counted.

Queries are independent of each other; that is, the segment given in each query will not be kept in the remaining queries.

Input Format

The input contains multiple testcases. The first line of the input contains an integer TT (1T1061 \le T \le 10^6), the number of testcases.

For each test case, the first line contains two integers n,qn, q (1n,q1061 \le n, q \le 10^6), the number of existing segments and the number of queries.

Each of the next nn lines contains two integers xi,yix_i, y_i (0xi,yi1090 \le x_i, y_i \le 10^9), describing a segment that starts at (xi,0)(x_i, 0) and ends at (0,yi)(0, y_i).

Then, each of the following qq lines contains three integers aj,bj,cja_j, b_j, c_j (0aj,bj,cj1090 \le a_j, b_j, c_j \le 10^9), describing a query segment that starts at (aj,0)(a_j, 0) and ends at (bj,cj)(b_j, c_j).

It’s guaranteed that the sum of nn and the sum of qq over all testcases does not exceed 10610^6, respectively.

Output Format

For each query, print YES if the query segment intersects (including at endpoints) with at least one of the existing segments, and NO otherwise.

1
3 5
6 6
2 6
6 2
10 4 4
10 3 3
0 1 1
0 2 2
5 2 1
NO
YES
NO
YES
NO