#P14790. [NERC 2025] Irrigation Interlock
[NERC 2025] Irrigation Interlock
题目描述
Two irrigation cooperatives share the same fertile valley. The first cooperative maintains pumps scattered across the fields; the second supervises reservoirs on the surrounding hills. Whenever both cooperatives decide to lay a pair of new pipes, the pipes must intersect — at such an intersection they can install a joint valve. Pipes always follow a straight line segment between a pair of distinct pumps or a pair of distinct reservoirs. Two pipes intersect if they share at least one common point (touching and overlapping pipes are considered intersecting).
You are given the exact coordinates of every pump and every reservoir on a Cartesian plane. For each planning scenario, determine whether the first cooperative can pick two distinct pumps and the second cooperative can pick two distinct reservoirs so that the two straight pipes intersect. If this is possible, report the indices of those pumps and reservoirs; otherwise declare that the project cannot be realized.
输入格式
The first line contains an integer () — the number of planning scenarios.
For each planning scenario:
- The first line contains an integer () — the number of pumps managed by the first cooperative.
- Each of the next lines contains two integers and () — the Cartesian coordinates of pump . The pump locations are distinct.
- The next line contains an integer () — the number of reservoirs managed by the second cooperative.
- Each of the next lines contains two integers and () — the Cartesian coordinates of reservoir . The reservoir locations are distinct.
No pump shares its location with any reservoir.
It is guaranteed that the sum of over all planning scenarios does not exceed and the sum of over all planning scenarios does not exceed .
输出格式
For each planning scenario:
- If the first cooperative can choose two pumps and the second cooperative can choose two reservoirs so that the straight pipes connecting each pair intersect, output four integers — the indices of two chosen pumps () and two chosen reservoirs ().
- If such an intersection is impossible, output .
- In case several valid solutions exist, any one of them is acceptable.
3
4
0 0
4 0
3 3
1 3
5
-1 1
5 1
2 -1
2 4
6 3
4
0 0
1 0
0 1
1 1
4
5 5
6 5
5 6
6 6
3
0 0
4 0
0 2
3
4 -2
4 2
6 1
1 4 1 2
-1
1 2 1 2
提示
:::align{center}
:::