QOJ.ac

QOJ

时间限制: 2 s 内存限制: 512 MB 总分: 100

#6594. Little Q's Draft

统计

Xiao Q is a programmer.

As everyone knows, programmers often need scratch paper when writing programs. Xiao Q now needs a piece of scratch paper to draw diagrams, but there is only one piece of scratch paper on the table that has been used many times.

The scratch paper can be viewed as a two-dimensional plane, and Xiao Q has even established a Cartesian coordinate system on it. The areas used in previous times can be approximated as triangles on the plane, and the interior and boundaries of these triangles cannot be used again. Naturally, the previously used areas do not overlap.

Xiao Q has already marked some key points on the scratch paper, and these points are in areas that have not been used. Xiao Q wants to connect as many pairs of these key points as possible with line segments. A line segment connecting two key points might pass through a previously used area, which is clearly not allowed. Therefore, Xiao Q wants to know how many pairs of key points can be connected by a line segment without passing through any previously used areas. For convenience, Xiao Q guarantees that no three key points are collinear.

Input

The first line contains two integers $V$ and $T$, representing the number of key points and the number of triangular areas on the scratch paper, respectively.

Next, $V$ lines each contain two integers $x, y$, representing the coordinates of a key point $(x, y)$.

Next, $T$ lines each contain six integers $x_1, y_1, x_2, y_2, x_3, y_3$, representing the coordinates of the three vertices of a triangular area $(x_1, y_1), (x_2, y_2), (x_3, y_3)$. It is guaranteed that the area of each triangle is greater than $0$.

Output

Output a single integer representing the number of pairs of key points that can be connected by a line segment.

Constraints

For $100\%$ of the test cases, $0 \le \text{all coordinates} \le 10^8$, and all coordinates are integers.

Test Case ID 1 2 3 4 5 6 7 8 9 10
$V$ 10 20 50 100 200 400 600 1000 1000 1000
$T$ 10 20 50 100 200 400 600 1000 1000 1000

Examples

Input 1

3 0
0 0
2 0
2 2

Output 1

3

Note 1

The entire scratch paper is brand new, so any two key points can be connected.

Input 2

3 1
0 0
2 0
2 2
1 0 1 1 2 1

Output 2

0

Note 2

As shown in the figure, the connection between any two key points is blocked.

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.