Logo
(追記) (追記ここまで)

35047번 - Irrigation Interlock 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB222100.000%

문제

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 $t$ (1ドル \le t \le 10^5$) --- the number of planning scenarios.

For each planning scenario:

The first line contains an integer $n$ (2ドル \le n \le 10^5$) --- the number of pumps managed by the first cooperative.

Each of the next $n$ lines contains two integers $x_i$ and $y_i$ ($|x_i|, |y_i| \le 10^9$) --- the Cartesian coordinates of pump $i$. The pump locations are distinct.

The next line contains an integer $m$ (2ドル \le m \le 10^5$) --- the number of reservoirs managed by the second cooperative.

Each of the next $m$ lines contains two integers $u_j$ and $v_j$ ($|u_j|, |v_j| \le 10^9$) --- the Cartesian coordinates of reservoir $j$. The reservoir locations are distinct.

No pump shares its location with any reservoir.

It is guaranteed that the sum of $n$ over all planning scenarios does not exceed 2ドル \cdot 10^5$ and the sum of $m$ over all planning scenarios does not exceed 2ドル \cdot 10^5$.

출력

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 $p_1,ドル $p_2,ドル $r_1,ドル $r_2$ --- the indices of two chosen pumps (1ドル \le p_1, p_2 \le n$; $p_1 \ne p_2$) and two chosen reservoirs (1ドル \le r_1, r_2 \le m$; $r_1 \ne r_2$).

If such an intersection is impossible, output $-1$.

In case several valid solutions exist, any one of them is acceptable.

제한

예제 입력 1

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

1 4 1 2
-1
1 2 1 2

노트

Planning scenario 1 Planning scenario 2 Planning scenario 3
  • Pump
  • Reservoir
  • Pipe

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > Northern Eurasia Finals 2025 I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /