#P1850G. The Morning Star
The Morning Star
题面翻译
题意简述
本题有多组数据。
给定 个点,第 个点的坐标为 ,。
现需要将星星和指南针放在任意两个点上,使得星星在指南针的正北、正东、正西、正南、正东南、正东北、正西南或正西北方向,求一共几种放法。(如果对此不太理解结合样例解释)
数据范围
输入格式
第一行输入一个,表示数据组数。
在每组数据中,输入,表示点的总数。
接下来 行,第行输入两个数 ,表示第个点的坐标。
输出格式
输出共行,每行一个整数,表示第组数据的结果。
说明/提示
在第一组数据中:
指南针在 ,星星在 ,在指南针的正西南方向。
指南针在 ,星星在 ,在指南针的正东北方向。
指南针在 ,星星在 ,在指南针的正东北方向。
指南针在,星星在,在指南针的正东北方向。
指南针在,星星在,在指南针的正西南方向。
指南针在,星星在,在指南针的正西南方向。
所以答案为6。
在第二组数据中:
指南针在,星星在,在指南针的正东北方向。
指南针在,星星在,在指南针的正西南方向。
所以答案是 2。
题目描述
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 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 ( ). The description of the test cases follows.
The first line of each test case contains a single integer ( ) — the number of points.
Then lines follow, each line containing two integers , ( ) — the coordinates of each point, all points have distinct coordinates.
It is guaranteed that the sum of over all test cases doesn't exceed .
输出格式
For each test case, output a single integer — the number of pairs of points that don't break the compass.
样例 #1
样例输入 #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 , the morning star is at : the compass will point .
- The compass is at , the morning star is at : the compass will point .
- The compass is at , the morning star is at : the compass will point .
- The compass is at , the morning star is at : the compass will point .
- The compass is at , the morning star is at : the compass will point .
- The compass is at , the morning star is at : the compass will point .
In the second test case, only two pairs of points won't break the compass:
- The compass is at , the morning star is at : the compass will point .
- The compass is at , the morning star is at : the compass will point .
相关
在以下作业中: