#P5545. [JSOI2016] 炸弹攻击2

[JSOI2016] 炸弹攻击2

Description

The game map is a two-dimensional plane. JYY's base is below the xx-axis, and all enemies are currently above the xx-axis.

In JYY's base, there are TT laser towers and SS launchers. The coordinates of the ii-th tower TiT_i are (txi,tyi)(tx_i,ty_i), and the coordinates of the ii-th launcher SiS_i are (sxi,syi)(sx_i,sy_i).

There are DD enemies on the map. The coordinates of the ii-th enemy DiD_i are (dxi,dyi)(dx_i,dy_i).

Two laser towers can be connected to form an energy wall. If the energy fired from a launcher toward an enemy passes through an energy wall, it can be greatly strengthened, becoming a super ray that instantly destroys the enemy.

JYY wants to know how many different attack plans can produce a super ray.

Specifically, an attack plan that can produce a super ray is a set of four points: {Ti,Tj,Sk,Dl}\{T_i,T_j,S_k,D_l\}, satisfying $1 \leq i < j \leq T,1 \leq k \leq S,1 \leq l \leq D$, and the line segment TiTjT_iT_j intersects the line segment SkDlS_kD_l.

The game guarantees that among these T+D+ST+D+S points, there are no duplicate points and no three points are collinear.

Input Format

The first line contains a positive integer DD.

The next DD lines each contain two integers dxi,dyidx_i,dy_i, representing the coordinates of an enemy.

Line D+1D+1 contains an integer SS.

The next SS lines each contain two integers sxi,syisx_i,sy_i, representing the coordinates of a launcher.

Line D+S+1D+S+1 contains an integer TT.

The next TT lines each contain two integers (txi,tyi)(tx_i,ty_i), representing the coordinates of a laser tower.

Output Format

Output one line containing one integer: the number of attack plans that can produce a super ray.

3
1 12
10 30
30 10
1
10 -10
4
2 -11
9 -1
11 -1
15 -14
7

Hint

For 20%20\% of the testdata, D,S,T30D,S,T \leq 30.

For 50%50\% of the testdata, D,S,T150D,S,T \leq 150.

For 100%100\% of the testdata, 1D,S,T800,dyi>0,syi,tyi<01 \leq D,S,T \leq 800, dy_i>0,sy_i,ty_i<0, and the absolute value of every coordinate does not exceed 10910^9.

Translated by ChatGPT 5