| Codeforces Round 1098 (Div. 2) |
|---|
| Finished |
Upon the mountain, Sanae gazes at the stars. Faith, for her, is where winds encounter one another and choices diverge, and it is the point where all directions meet. For the glory of the Holy Cross, let us trace the sign of faith together.
There are $$$n$$$ distinct integer points in the plane, where the $$$i$$$-th point is located at $$$(x_i,y_i)$$$. To color the points, choose two integers $$$k_1$$$ and $$$k_2$$$ such that each of the four regions divided by the lines $$$x=k_1+0.5$$$ and $$$y=k_2+0.5$$$ contains at least one point. Each point $$$(x,y)$$$ is colored according to the region it lies in:
A valid coloring of the third test case, where $$$k_1=4$$$ and $$$k_2=5$$$. Find the number of distinct colorings, where two colorings are considered distinct if and only if there exists at least one point colored differently, regardless of the choice of $$$k_1$$$ and $$$k_2$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains an integer $$$n$$$ ($$$4 \leq n \leq 2 \cdot 10^6$$$).
The following $$$n$$$ lines each contain two integers $$$x_i$$$, $$$y_i$$$ ($$$1 \leq x_i, y_i \leq n$$$), representing the coordinates of the $$$i$$$-th point.
It is guaranteed that the points are pairwise distinct in each test case.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^6$$$.
For each test case, output the number of distinct colorings.
541 12 23 34 441 44 11 14 487 25 72 71 36 73 67 51 686 13 61 41 14 25 53 44 165 55 43 51 55 32 2
011284
In the first test case, no valid cross exists.
In the second test case, choosing $$$x = y = 2$$$ yields a valid coloring. It can be proved that this coloring is unique.
In the third test case, a valid coloring is shown in the legend.
| Name |
|---|


