Codeforces Round 971 (Div. 4) |
---|
Finished |
Satyam is given $$$n$$$ distinct points on the 2D coordinate plane. It is guaranteed that $$$0 \leq y_i \leq 1$$$ for all given points $$$(x_i, y_i)$$$. How many different nondegenerate right triangles$$$^{\text{∗}}$$$ can be formed from choosing three different points as its vertices?
Two triangles $$$a$$$ and $$$b$$$ are different if there is a point $$$v$$$ such that $$$v$$$ is a vertex of $$$a$$$ but not a vertex of $$$b$$$.
$$$^{\text{∗}}$$$A nondegenerate right triangle has positive area and an interior $$$90^{\circ}$$$ angle.
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases.
The first line of each test case contains an integer $$$n$$$ ($$$3 \leq n \leq 2 \cdot 10^5$$$) — the number of points.
The following $$$n$$$ lines contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \leq x_i \leq n$$$, $$$0 \leq y_i \leq 1$$$) — the $$$i$$$'th point that Satyam can choose from. It is guaranteed that all $$$(x_i, y_i)$$$ are pairwise distinct.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
Output an integer for each test case, the number of distinct nondegenerate right triangles that can be formed from choosing three points.
351 01 13 05 02 130 01 03 091 02 03 04 05 02 17 18 19 1
4 0 8
The four triangles in question for the first test case:
Name |
---|