CF1850G.The Morning Star

普及/提高-

通过率:0%

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?

输入格式

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

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

Then nn lines follow, each line containing two integers xix_i , yiy_i ( 109xi,yi109-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 21052 \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} .
首页