#P13588. [NWRRC 2023] H-Shaped Figures
[NWRRC 2023] H-Shaped Figures
题目描述
After a huge success of the last year's "K-Shaped Figures" problem, we've come up with an innovative "H-Shaped Figures" problem for this year. And we have some plans for the next 24 years.
Let's say that three segments , , and on a plane form an H-shaped figure if:
- point lies strictly inside segment , and segments and are not collinear;
- point lies strictly inside segment , and segments and are not collinear;
- segments and do not have common points.
You are given the coordinates of points and , along with candidate segments for and . Note that some of the given segments may coincide, but they should still be treated as different segments.
Find the number of possible ways to choose one of the given segments as and another one as to form an H-shaped figure along with the given segment .
输入格式
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains four integers , denoting the coordinates of points and (). Points and do not coincide.
The second line contains a single integer , denoting the number of candidate segments ().
The -th of the following lines contains four integers , denoting the coordinates of the endpoints of the -th segment ($-10^9 \le x_{i,1}, y_{i,1}, x_{i,2}, y_{i,2} \le 10^9$). All segments have positive lengths.
It is guaranteed that the sum of over all test cases does not exceed .
输出格式
For each test case, print the number of ways to form an H-shaped figure using the given segment and two of the candidate segments.
1
0 0 4 0
8
0 0 2 1
-1 -1 2 2
3 3 5 -3
0 2 6 -1
2 -2 5 1
-1 1 3 -3
-1 0 2 0
-1 -1 2 2
6