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 nn 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)。若指向其他任意方向,指南针将损坏。

指南针可指向的方向。

平面上有 nn 个互异的整数坐标点。问:有多少种方式选择一个点放置指南针、另一个点作为晨星,使得指南针不会损坏?

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains a single integer nn (2≤n≤2⋅1052 \leq n \leq 2 \cdot 10^5) — the number of points.

Then nn lines follow, each line containing two integers xix_i, yiy_i (−109≤xi,yi≤109-10^9 \leq x_i, y_i \leq 10^9) — the coordinates of each point, all points have distinct coordinates.

It is guaranteed that the sum of nn over all test cases doesn't exceed 2⋅1052 \cdot 10^5.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1041 \le t \le 10^4)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(2≤n≤2⋅1052 \leq n \leq 2 \cdot 10^5)—— 表示点的数量。

接下来是 nn 行,每行包含两个整数 xix_i、yiy_i(−109≤xi,yi≤109-10^9 \leq x_i, y_i \leq 10^9)—— 表示每个点的坐标,所有点的坐标互不相同。

保证所有测试用例的 nn 之和不超过 2⋅1052 \cdot 10^5。

输出格式

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)(0,0), the morning star is at (−1,−1)(-1,-1): the compass will point SW\text{SW}.
  • The compass is at (0,0)(0,0), the morning star is at (1,1)(1,1): the compass will point NE\text{NE}.
  • The compass is at (−1,−1)(-1,-1), the morning star is at (0,0)(0,0): the compass will point NE\text{NE}.
  • The compass is at (−1,−1)(-1,-1), the morning star is at (1,1)(1,1): the compass will point NE\text{NE}.
  • The compass is at (1,1)(1,1), the morning star is at (0,0)(0,0): the compass will point SW\text{SW}.
  • The compass is at (1,1)(1,1), the morning star is at (−1,−1)(-1,-1): the compass will point SW\text{SW}.

In the second test case, only two pairs of points won't break the compass:

  • The compass is at (6,9)(6,9), the morning star is at (10,13)(10,13): the compass will point NE\text{NE}.
  • The compass is at (10,13)(10,13), the morning star is at (6,9)(6,9): the compass will point SW\text{SW}.

在第一个测试用例中,任意一对点都不会使罗盘失效:

  • 罗盘位于 (0,0)(0,0),启明星位于 (−1,−1)(-1,-1):罗盘指向 SW\text{SW}。
  • 罗盘位于 (0,0)(0,0),启明星位于 (1,1)(1,1):罗盘指向 NE\text{NE}。
  • 罗盘位于 (−1,−1)(-1,-1),启明星位于 (0,0)(0,0):罗盘指向 NE\text{NE}。
  • 罗盘位于 (−1,−1)(-1,-1),启明星位于 (1,1)(1,1):罗盘指向 NE\text{NE}。
  • 罗盘位于 (1,1)(1,1),启明星位于 (0,0)(0,0):罗盘指向 SW\text{SW}。
  • 罗盘位于 (1,1)(1,1),启明星位于 (−1,−1)(-1,-1):罗盘指向 SW\text{SW}。

在第二个测试用例中,仅有两对点不会使罗盘失效:

  • 罗盘位于 (6,9)(6,9),启明星位于 (10,13)(10,13):罗盘指向 NE\text{NE}。
  • 罗盘位于 (10,13)(10,13),启明星位于 (6,9)(6,9):罗盘指向 SW\text{SW}。

输入解题思路,AI测评打分。不知道怎么写?

首页