CF621B.Wet Shark and Bishops
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Today, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to bottom, while columns are numbered from left to right.
Wet Shark thinks that two bishops attack each other if they share the same diagonal. Note, that this is the only criteria, so two bishops may attack each other (according to Wet Shark) even if there is another bishop located between them. Now Wet Shark wants to count the number of pairs of bishops that attack each other.
今天,Wet Shark 在一个 1000×1000 的网格上放置了 n 个主教(象)。网格的行和列均编号为 1 到 1000。行号从上到下递增,列号从左到右递增。
Wet Shark 认为:若两个主教位于同一条对角线上,则它们彼此攻击。注意,这是唯一的判定条件;因此,即使两个主教之间存在另一个主教,它们仍被 Wet Shark 视为彼此攻击。现在,Wet Shark 想要计算彼此攻击的主教对的数量。
输入格式
The first line of the input contains n (1 ≤ n ≤ 200 000) — the number of bishops.
Each of next n lines contains two space separated integers x__i and y__i (1 ≤ x__i, y__i ≤ 1000) — the number of row and the number of column where i-th bishop is positioned. It's guaranteed that no two bishops share the same position.
输入的第一行包含一个整数 n(1≤n≤200000)—— 表示主教的数量。
接下来的 n 行中,每行包含两个以空格分隔的整数 xi 和 yi(1≤xi,yi≤1000)—— 分别表示第 i 个主教所在的行号和列号。保证任意两个主教不会位于同一位置。
输出格式
Output one integer — the number of pairs of bishops which attack each other.
输出一个整数——互相攻击的主教对的数量。
输入输出样例
输入#1
5 1 1 1 5 3 3 5 1 5 5
输出#1
6
输入#2
3 1 1 2 3 3 5
输出#2
0
说明/提示
In the first sample following pairs of bishops attack each other: (1, 3), (1, 5), (2, 3), (2, 4), (3, 4) and (3, 5). Pairs (1, 2), (1, 4), (2, 5) and (4, 5) do not attack each other because they do not share the same diagonal.
在第一个样例中,以下几对主教相互攻击:(1, 3)、(1, 5)、(2, 3)、(2, 4)、(3, 4) 和 (3, 5)。而 (1, 2)、(1, 4)、(2, 5) 和 (4, 5) 这几对主教不相互攻击,因为它们不位于同一条对角线上。
输入解题思路,AI测评打分。不知道怎么写?