博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Round #345 C. Watchmen(Div.2)
阅读量:5142 次
发布时间:2019-06-13

本文共 1750 字,大约阅读时间需要 5 分钟。

Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (xi, yi).

They need to arrange a plan, but there are some difficulties on their way. As you know, Doctor Manhattan considers the distance between watchmen i and j to be |xi - xj| + |yi - yj|. Daniel, as an ordinary person, calculates the distance using the formula .

The success of the operation relies on the number of pairs (i, j) (1 ≤ i < j ≤ n), such that the distance between watchman i and watchmen j calculated by Doctor Manhattan is equal to the distance between them calculated by Daniel. You were asked to compute the number of such pairs.

Input

The first line of the input contains the single integer n (1 ≤ n ≤ 200 000) — the number of watchmen.

Each of the following n lines contains two integers xi and yi (|xi|, |yi| ≤ 109).

Some positions may coincide.

Output

Print the number of pairs of watchmen such that the distance between them calculated by Doctor Manhattan is equal to the distance calculated by Daniel.

Examples
input
3 1 1 7 5 1 5
output
2
input
6 0 0 0 1 0 2 -1 1 0 1 1 1
output
11
Note

In the first sample, the distance between watchman 1 and watchman 2 is equal to |1 - 7| + |1 - 5| = 10 for Doctor Manhattan and  for Daniel. For pairs (1, 1), (1, 5) and (7, 5), (1, 5)Doctor Manhattan and Daniel will calculate the same distances.

 

 

1 #include 
2 #include
3 using namespace std; 4 struct Node 5 { 6 int x; 7 int y; 8 }a[200005]; 9 int cmp1(Node a,Node b)10 {11 if(a.x==b.x)12 return a.y

 

转载于:https://www.cnblogs.com/z-712/p/7323580.html

你可能感兴趣的文章
windows环境下搭建RocketMQ
查看>>
CSS--基础
查看>>
基于OpenGL的渲染引擎
查看>>
Android HTTP GET 小文件下载
查看>>
ember.js:使用笔记4 数组数据的分组显示
查看>>
mvc-9测试和调试
查看>>
移植linux-2.6.32.2到qq2440
查看>>
转义字符(\)对JavaScript中JSON.parse的影响概述
查看>>
MySQL学习9 - 单表查询
查看>>
利用kubeadm部署k8s
查看>>
如何在MVC中显示条形码图片(以内存流的方式)
查看>>
解析文件夹下的所有二维码,并输出二维码中的信息
查看>>
高精度加减
查看>>
表单验证
查看>>
python细节2
查看>>
游戏引擎 Unity 的入门易精通难体现在哪?为什么?
查看>>
用标签、按钮和文本框编辑一个个人信息简介页面
查看>>
SQL查询xml内容
查看>>
jzoj5813
查看>>
HttpServletRequest 获取URL的方法及区别
查看>>