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

18051번 - Antennas 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초 512 MB219850.000%

문제

In a secret military base, a new communication technology is being tested. For the experiment, m antennas were constructed inside.

The terrain around the base is perfectly flat, and the base, seen from above, is a convex polygon. The boundary of the polygon is a wall that protects the base from intruders, as well as blocks the radio waves from leaving the base to be possibly intercepted by foreign agents.

Unfortunately, some construction works are required in the facility, and two of the polygon’s walls must be torn down. This creates a security risk: if two spies are placed outside the base in such a way that two of the antennas lie on the line between them, and there is no wall blocking this line, then the spies may listen to the communication between those two antennas.

Your goal is, for some possible scenarios of removal of two walls, to determine the number of pairs of antennas which are compromised in the way described above.

The picture above corresponds to the first case of the example input from the “Example” section. In this case, the base is a pentagon with four antennas, denoted by little crosses. All the lines between pairs of antennas are also shown.

입력

The first line of input contains the number of test cases z (1 ≤ z ≤ 200 000). The test cases follow, each one in the following format:

The first line of a test case contains an integer n (3 ≤ n ≤ 10) – the number of vertices of the polygon. The next n lines contain two integers – the coordinates of the vertices, presented clockwise. The vertices are numbered 0, 1, . . . , n − 1 in order in which they appear.

The next line contains an integer m (2 ≤ m ≤ 50 000) – the number of antennas inside the base – and the m following lines contain the coordinates of the antennas.

The next line contains another integer q (1 ≤ q ≤ 10) – the number of scenarios to consider. The last q lines describe scenarios – the i-th line contains two integers ai, bi (0 ≤ ai < bin−1). Such a pair denotes removing the walls ai and bi and requires to compute the number of distinct lines that go through some two antennas and do not cross neither the segment between the vertices ai and ai + 1 nor the segment between bi and (bi + 1) mod n.

All coordinates are integers whose absolute values do not exceed 109. In any single testcase, all points of the input are distinct and no three of them are collinear.

Every test case, including the first, is preceded by a single empty line.

The sum of all m values in all test cases does not exceed 300 000.

출력

For every testcase output, in separate lines, the answers to all given scenarios.

제한

예제 입력 1

2
5
0 0
0 5
3 7
6 5
6 0
4
1 2
1 3
5 2
5 3
3
0 3
1 4
1 2
4
-1 -1
-1 1
2 1
2 -1
2
0 0
1 0
6
0 1
0 2
0 3
1 2
1 3
2 3

예제 출력 1

4 1 0
0 1 0 0 0 0

힌트

출처

ICPC > Regionals > Europe > Central European Regional Contest > Poland Collegiate Programming Contest > AMPPZ 2019 J번

Contest > Open Cup > 2019/2020 Season > Stage 8: Grand Prix of Poland J번

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

출처

대학교 대회

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

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