Problem11274--[yosupo] Geometry - Count Points in Triangles

11274: [yosupo] Geometry - Count Points in Triangles

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

Given 2D-points $A _ k=(x _ k, y _ k)$ $(k=0,1,\ldots ,N-1)$ and 2D-points $B _ k=(p _ k, q _ k)$ $(k=0,1,\ldots ,M-1)$ . Process the following $Q$ queries in order.

* Given $a$ , $b$ , $c$ . Please output the number of points in $B _ 0,B _ 1,\ldots ,B _ {M-1}$ included in the convex hull of $3$ points $A _ a,A _ b,A _ c$ (exclude border) .

Input

$N$
$x _ 0$ $y _ 0$
$x _ 1$ $y _ 1$
$\ \vdots$
$x _ {N-1}$ $y _ {N-1}$
$M$
$p _ 0$ $q _ 0$
$p _ 1$ $q _ 1$
$\ \vdots$
$p _ {M-1}$ $q_{M-1}$
$Q$
$a$ $b$ $c$
$\ \vdots$
$a$ $b$ $c$

Constraints

- $1 \leq N \leq 500$
- $1 \leq M \leq 500$
- $|x _ i|, |y _ i| \leq 10^9$
- $|p _ i|, |q _ i| \leq 10^9$
- $1 \leq Q \leq 10^6$
- $0 \leq a,b,c \lt N$
- They are all integers.

Sample 1 Input

5
-1 -1
-1 2
2 -1
2 2
5 5
5
0 0
0 1
1 0
1 1
1 1
4
0 1 2
3 3 3
0 3 4
1 4 2

Sample 1 Output

1
0
0
2

HINT

Yosupo.

Source/Category