#P7934. Triangle Area and Point Inclusion

    ID: 21118 Type: Default 1000ms 256MiB

Triangle Area and Point Inclusion

Triangle Area and Point Inclusion

Given the coordinates of the three vertices of a triangle and the coordinates of N points, compute the area of the triangle and determine how many of the N points lie inside the triangle (including the boundary).

The area of a triangle with vertices \( (x_1, y_1) \), \( (x_2, y_2) \), \( (x_3, y_3) \) can be computed using the formula:

\( Area = \frac{1}{2} \left| x_1(y_2-y_3) + x_2(y_3-y_1) + x_3(y_1-y_2) \right| \)

A point \( (x, y) \) is considered inside the triangle if the sum of the areas of the triangles formed by \( (x, y) \) with each pair of triangle vertices is equal to the area of the original triangle (allowing slight tolerance for floating point computations).

inputFormat

The first line contains six numbers: x1 y1 x2 y2 x3 y3, which are the coordinates of the three vertices of the triangle.

The second line contains an integer N denoting the number of points.

The following N lines each contain two numbers x y, representing the coordinates of a point.

outputFormat

Output the area of the triangle followed by the number of points that lie inside (or on the boundary) of the triangle. The two values should be separated by a space.

sample

0 0 5 0 0 5
3
1 1
2 2
-1 -1
12.5 2