CF1850G.The Morning Star
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A compass points directly toward the morning star. It can only point in one of eight directions: the four cardinal directions (N, S, E, W) or some combination (NW, NE, SW, SE). Otherwise, it will break.
The directions the compass can point.
There are n distinct points with integer coordinates on a plane. How many ways can you put a compass at one point and the morning star at another so that the compass does not break?
指南针始终精确指向晨星。它只能指向八个方向之一:四个基本方向(北 N、南 S、东 E、西 W)或其组合(西北 NW、东北 NE、西南 SW、东南 SE)。若指向其他任意方向,指南针将损坏。
指南针可指向的方向。
平面上有 n 个互异的整数坐标点。问:有多少种方式选择一个点放置指南针、另一个点作为晨星,使得指南针不会损坏?
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The first line of each test case contains a single integer n (2≤n≤2⋅105) — the number of points.
Then n lines follow, each line containing two integers xi, yi (−109≤xi,yi≤109) — the coordinates of each point, all points have distinct coordinates.
It is guaranteed that the sum of n over all test cases doesn't exceed 2⋅105.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(2≤n≤2⋅105)—— 表示点的数量。
接下来是 n 行,每行包含两个整数 xi、yi(−109≤xi,yi≤109)—— 表示每个点的坐标,所有点的坐标互不相同。
保证所有测试用例的 n 之和不超过 2⋅105。
输出格式
For each test case, output a single integer — the number of pairs of points that don't break the compass.
对于每个测试用例,输出一个整数——即不破坏圆规条件的点对数量。
输入输出样例
输入#1
5 3 0 0 -1 -1 1 1 4 4 5 5 7 6 9 10 13 3 -1000000000 1000000000 0 0 1000000000 -1000000000 5 0 0 2 2 -1 5 -1 10 2 11 3 0 0 -1 2 1 -2
输出#1
6 2 6 8 0
说明/提示
In the first test case, any pair of points won't break the compass:
- The compass is at (0,0), the morning star is at (−1,−1): the compass will point SW.
- The compass is at (0,0), the morning star is at (1,1): the compass will point NE.
- The compass is at (−1,−1), the morning star is at (0,0): the compass will point NE.
- The compass is at (−1,−1), the morning star is at (1,1): the compass will point NE.
- The compass is at (1,1), the morning star is at (0,0): the compass will point SW.
- The compass is at (1,1), the morning star is at (−1,−1): the compass will point SW.
In the second test case, only two pairs of points won't break the compass:
- The compass is at (6,9), the morning star is at (10,13): the compass will point NE.
- The compass is at (10,13), the morning star is at (6,9): the compass will point SW.
在第一个测试用例中,任意一对点都不会使罗盘失效:
- 罗盘位于 (0,0),启明星位于 (−1,−1):罗盘指向 SW。
- 罗盘位于 (0,0),启明星位于 (1,1):罗盘指向 NE。
- 罗盘位于 (−1,−1),启明星位于 (0,0):罗盘指向 NE。
- 罗盘位于 (−1,−1),启明星位于 (1,1):罗盘指向 NE。
- 罗盘位于 (1,1),启明星位于 (0,0):罗盘指向 SW。
- 罗盘位于 (1,1),启明星位于 (−1,−1):罗盘指向 SW。
在第二个测试用例中,仅有两对点不会使罗盘失效:
- 罗盘位于 (6,9),启明星位于 (10,13):罗盘指向 NE。
- 罗盘位于 (10,13),启明星位于 (6,9):罗盘指向 SW。
输入解题思路,AI测评打分。不知道怎么写?