QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 512 MB Points totaux : 100

#6221. Bomb Attack 2

Statistiques

Do you remember the tower defense game titled "Bomb Attack"? This game has a sequel, and the power of the bombs has been greatly increased.

The game map is a 2D plane. JYY's base is located below the $x$-axis, while all enemies are currently located above the $x$-axis.

In JYY's base, there are $T$ laser towers and $S$ energy emitters. The $i$-th defensive tower $T_i$ has coordinates $(tx_i, ty_i)$, and the $i$-th energy emitter $S_i$ has coordinates $(sx_i, sy_i)$.

There are $D$ enemies on the map, and the $i$-th enemy $D_i$ has coordinates $(dx_i, dy_i)$.

Two laser towers can be connected to form an energy wall. If the energy emitted from an emitter toward an enemy passes through an energy wall, it receives a massive boost, becoming a "super ray" that instantly eliminates the enemy.

JYY wants to know how many ways he can fire a super ray.

Specifically, an attack plan that can fire a super ray is a set of four points $\{T_i, T_j, S_k, D_l\}$ satisfying $1 \le i < j \le T$, $1 \le k \le S$, and $1 \le l \le D$, such that the line segment $T_i T_j$ and the line segment $S_k D_l$ intersect.

The game settings guarantee that among these $T + D + S$ points, there are no coincident points and no three points are collinear.

Input

The first line contains a positive integer $D$. The next $D$ lines each contain two integers $dx_i, dy_i$ ($dy_i > 0$), representing the coordinates of an enemy. The next line contains an integer $S$. The next $S$ lines each contain two integers $sx_i, sy_i$ ($sy_i < 0$), representing the coordinates of an energy emitter. The next line contains an integer $T$. The next $T$ lines each contain two integers $tx_i, ty_i$ ($ty_i < 0$), representing the coordinates of a laser tower.

Output

Output a single integer representing the number of attack plans that can fire a super ray.

Examples

Input 1

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

Output 1

7

Constraints

  • For 20% of the data, $D, S, T \le 30$.
  • For 50% of the data, $D, S, T \le 150$.
  • For 100% of the data, $1 \le D, S, T \le 800$, and the absolute values of all coordinates do not exceed $10^9$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.