QOJ.ac

QOJ

Limite de temps : 3 s Limite de mémoire : 256 MB Points totaux : 100

#10790. Extreme Point Statistics

Statistiques

For a set $S$ of points in a plane and a point $p$ in the plane, the function $f(p, S)$ has a value of 1 if and only if $p$ is inside the convex hull of $S$ (including the boundary of the convex hull of $S$), and 0 otherwise.

Given two sets of points in the plane, $P = \{p_1, p_2, \dots, p_N\}$ and $A = \{a_1, a_2, \dots, a_M\}$, we call a point $a_i$ in $A$ an extreme point if and only if it satisfies:

$$\sum_{j \neq i} f(a_i, P \cup \{a_j\}) = 0$$

In other words, $a_i$ is not inside the convex hull formed by $P$ and any point $a_j$ in $A$ where $j \neq i$.

Please count the number of extreme points in set $A$.

Input

The first line contains two space-separated positive integers $N$ and $M$. The second line contains $N$ space-separated pairs of integers, where the $i$-th pair $(x_i^p, y_i^p)$ represents the coordinates of point $p_i$. The third line contains $M$ space-separated pairs of integers, where the $j$-th pair $(x_j^a, y_j^a)$ represents the coordinates of point $a_j$.

For any single set, the input data guarantees that no two points have the same coordinates.

Output

Output a single integer representing the number of extreme points in set $A$.

Examples

Input 1

4 5
6 3 7 -1 -6 -5 1 5
-5 -5 7 -5 9 -9 -10 11 -5 -6

Output 1

3

Note 1

The extreme points are $(-10, 11)$, $(9, -9)$, and $(-5, -6)$.

Constraints

  • For 10% of the data, $M = 1$.
  • For 30% of the data, $N, M \le 50$.
  • For another 30% of the data, $N \le 10$, $M \le 20000$.
  • For 100% of the data, $3 \le N \le 10^5$, $1 \le M \le 10^5$, $|x_i|, |y_i| \le 10^6$, and the area of the convex hull of set $P$ is non-zero.

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.