题意:两点(x1,y1), (x2,y2)的曼哈顿距离=欧几里得距离

也就是:x1=x2或y1=y2,再删除重合点造成的重复计数即可。

 #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <stack>
#define clc(a,b) memset(a,b,sizeof(a))
#define LL long long
using namespace std;
const int maxn=;
const int inf=0x3f3f3f3f;
struct node{
LL x,y;
}a[maxn];
bool cmp1(node a,node b){
if(a.x==b.x) return a.y<b.y;
return a.x<b.x;
} bool cmp2(node a,node b){
if(a.y==b.y) return a.x<b.x;
return a.y<b.y;
} int n;
// int a[maxn],b[maxn];
int main(){
scanf("%d",&n);
LL sum=;
for(int i=;i<n;i++){
scanf("%I64d%I64d",&a[i].x,&a[i].y);
}
sort(a,a+n,cmp1);
LL sum1=;
for(int i=;i<n;i++){
int j=i;
sum1=;
while(j<n&&a[i].x==a[j].x){
sum1++;
j++;
}
i=j-;
sum+=sum1*(sum1-)/;
}
sort(a,a+n,cmp2);
sum1=;
for(int i=;i<n;i++){
int j=i;
sum1=;
while(j<n&&a[i].y==a[j].y){
sum1++;
j++;
}
i=j-;
sum+=sum1*(sum1-)/;
}
sum1=;
for(int i=;i<n;i++){
int j=i;
sum1=;
while(j<n&&a[i].y==a[j].y&&a[j].x==a[i].x){
sum1++;
j++;
}
i=j-;
sum-=sum1*(sum1-)/;
}
printf("%I64d\n",sum);
return ;
}

codeforces Codeforces 650A Watchmen的更多相关文章

  1. Codeforces Codeforces Round #484 (Div. 2) E. Billiard

    Codeforces Codeforces Round #484 (Div. 2) E. Billiard 题目连接: http://codeforces.com/contest/982/proble ...

  2. Codeforces Codeforces Round #484 (Div. 2) D. Shark

    Codeforces Codeforces Round #484 (Div. 2) D. Shark 题目连接: http://codeforces.com/contest/982/problem/D ...

  3. (水题)Codeforces - 650A - Watchmen

    http://codeforces.com/contest/650/problem/A 一开始想了很久都没有考虑到重复点的影响,解欧拉距离和曼哈顿距离相等可以得到 $x_i=x_j$ 或 $y_i=y ...

  4. Codeforces 650A Watchmen

    传送门 time limit per test 3 seconds memory limit per test 256 megabytes input standard input output st ...

  5. CodeForces 651 C Watchmen

    C. Watchmen time limit per test 3 seconds memory limit per test 256 megabytes input standard input o ...

  6. codeforces 650 C. Watchmen(数学公式)

    C. Watchmen time limit per test 3 seconds memory limit per test 256 megabytes input standard input o ...

  7. 【CodeForces - 651C 】Watchmen(map)

    Watchmen 直接上中文 Descriptions: 钟表匠们的好基友马医生和蛋蛋现在要执行拯救表匠们的任务.在平面内一共有n个表匠,第i个表匠的位置为(xi, yi). 他们需要安排一个任务计划 ...

  8. Codeforces Codeforces Round #316 (Div. 2) C. Replacement set

    C. Replacement Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/proble ...

  9. Codeforces Codeforces Round #316 (Div. 2) C. Replacement 线段树

    C. ReplacementTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/problem ...

随机推荐

  1. eclipse下使用java调用weka(转)

    原文链接:http://blog.csdn.net/felomeng/article/details/4688257 weka是很好用的机器学习库,这里就不详细介绍了. 言归正传,要使用程序方式使用w ...

  2. c#NPOI导出

    按行列导出数据: HSSFWorkbook hssfworkbook = new HSSFWorkbook(); //命名空间:using NPOI.HSSF.UserModel; Sheet she ...

  3. onmouseleave与onmouseout区别

    1.onmouseleave.onmouseenter,鼠标进入到指定元素区域内触发事件,不支持冒泡,不包含子元素的区域. 2.onmouseout.onmouseover.鼠标进入指定元素触发事件, ...

  4. yii2源码学习笔记(十九)

    view剩余代码 /** * @return string|boolean the view file currently being rendered. False if no view file ...

  5. asp.net core 认证及简单集群

    众所周知,在Asp.net WebAPI中,认证是通过AuthenticationFilter过滤器实现的,我们通常的做法是自定义AuthenticationFilter,实现认证逻辑,认证通过,继续 ...

  6. 【面试】蘑菇街产品运营二面&结果

    2015-08-25 今天下午大概三点半接到了杭州的电话,是蘑菇街的面试官,面试官一开始就说我们简单做个15分钟的面试吧.首先,让我做一个与产品经历相关的自我介绍,我说了自己的产品实习和两个产品比赛经 ...

  7. C++的类和对象

    #include <iostream> // 预处理命令 using namespace std; class Student{ // 声明一个类,类名为Student private : ...

  8. Word续上表

    选中表格的下半部分(全部下半部分),然后按ctrl+shift+enter,这样就换行了.

  9. 【转载】JavaEE权限管理分析

    JavaEE权限管理分析 一.背景 在 Web 应用开发中,安全一直是非常重要的一个方面.安全虽然属于应用的非功能性需求,但是应该在应用开发的初期就考虑进来.如果在应用开发的后期才考虑安全的问题,就可 ...

  10. hdu 4752

    计算几何+数值计算的题目: 要用到辛普森积分,没有学过~~~ 参考学习了acm_Naruto大神 的代码! 代码: #include<cstdio> #include<cmath&g ...