A16160 | The Morning Star
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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?
 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?
输入格式
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 a single integer $n$ ( $2 \leq n \leq 2 \cdot 10^5$ ) — the number of points.
Then $n$ lines follow, each line containing two integers $x_i$ , $y_i$ ( $-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 $n$ over all test cases doesn't exceed $2 \cdot 10^5$ .
The first line of each test case contains a single integer $n$ ( $2 \leq n \leq 2 \cdot 10^5$ ) — the number of points.
Then $n$ lines follow, each line containing two integers $x_i$ , $y_i$ ( $-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 $n$ over all test cases doesn't exceed $2 \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)$ , the morning star is at $(-1,-1)$ : the compass will point $\text{SW}$ .
- The compass is at $(0,0)$ , the morning star is at $(1,1)$ : the compass will point $\text{NE}$ .
- The compass is at $(-1,-1)$ , the morning star is at $(0,0)$ : the compass will point $\text{NE}$ .
- The compass is at $(-1,-1)$ , the morning star is at $(1,1)$ : the compass will point $\text{NE}$ .
- The compass is at $(1,1)$ , the morning star is at $(0,0)$ : the compass will point $\text{SW}$ .
- The compass is at $(1,1)$ , the morning star is at $(-1,-1)$ : the compass will point $\text{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 $\text{NE}$ .
- The compass is at $(10,13)$ , the morning star is at $(6,9)$ : the compass will point $\text{SW}$ .
- The compass is at $(0,0)$ , the morning star is at $(-1,-1)$ : the compass will point $\text{SW}$ .
- The compass is at $(0,0)$ , the morning star is at $(1,1)$ : the compass will point $\text{NE}$ .
- The compass is at $(-1,-1)$ , the morning star is at $(0,0)$ : the compass will point $\text{NE}$ .
- The compass is at $(-1,-1)$ , the morning star is at $(1,1)$ : the compass will point $\text{NE}$ .
- The compass is at $(1,1)$ , the morning star is at $(0,0)$ : the compass will point $\text{SW}$ .
- The compass is at $(1,1)$ , the morning star is at $(-1,-1)$ : the compass will point $\text{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 $\text{NE}$ .
- The compass is at $(10,13)$ , the morning star is at $(6,9)$ : the compass will point $\text{SW}$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted