#P6149. [USACO20FEB] Triangles S
[USACO20FEB] Triangles S
Description
Farmer John wants to build a triangular pasture for his cows.
There are () fence posts located at distinct points on the 2D plane of the farm. He may choose any three points to form a triangular pasture, as long as one side of the triangle is parallel to the -axis and another side is parallel to the -axis.
What is the sum of the areas of all possible pastures that FJ can form?
Input Format
The first line contains .
The next lines each contain two integers and , both in the range , describing the position of a fence post.
Output Format
Since the sum of areas may not be an integer and may be very large, output the remainder of twice the sum of areas modulo .
4
0 0
0 1
1 0
1 2
3
Hint
Sample Explanation:
The fence posts , , and form a triangle with area , and the fence posts , , and form a triangle with area . Therefore, the answer is .
Subtasks:
- Test case satisfies .
- Test cases - satisfy .
- Test cases - have no additional constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号