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

    ID: 17205 Type: RemoteJudge 2000ms 2048MiB Tried: 0 Accepted: 0 Difficulty: 9 Uploaded By: Tags>二分2025上海凸包ICPC

[ICPC 2025 Shanghai R] Flower' s land 4

题目描述

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 xi≥0x_i \ge 0, and its ending point has coordinates (0,yi)(0, y_i) with yi≥0y_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.

输入格式

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

For each test case, the first line contains two integers n,qn, q (1≤n,q≤1061 \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 (0≤xi,yi≤1090 \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 (0≤aj,bj,cj≤1090 \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.

输出格式

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