题意:两点(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. bzoj3351:[ioi2009]Regions

    思路:首先如果颜色相同直接利用以前的答案即可,可以离线排序或是在线hash,然后考虑怎么快速统计答案. 首先如果点a是点b的祖先,那么一定有点b在以点a为根的子树的dfs序区间内的,于是先搞出dfs序 ...

  2. 【C++11】新特性——Lambda函数

    本篇文章由:http://www.sollyu.com/c11-new-lambda-function/ 文章列表 本文章为系列文章 [C++11]新特性--auto的使用 http://www.so ...

  3. js 判断数组中是否存在

    /* 判断数组中是否存在 var somearray = ["mon", "tue", "wed", "thur"] s ...

  4. javascript 写职责链

    我认为职责链最大的目的在于解决对一个对象的加工过程问题.并且如何通过filter在什么时机截止操作流程 /** * by JackChen 2016-3-14 15.16.53 * 职责链 * 看马士 ...

  5. 深度学习算法实践15---堆叠去噪自动编码机(SdA)原理及实现

    我们讨论了去噪自动编码机(dA),并讨论了Theano框架实现的细节.在本节中,我们将讨论去噪自动编码机(dA)的主要应用,即组成堆叠自动编码机(SdA),我们将以MNIST手写字母识别为例,用堆叠自 ...

  6. JFreeChart入学教程

    JFreeChart入学教程 2011-08-08 14:55:19|  分类: 技术篇 |举报 |字号 订阅   JFreeChart 是一组功能强大.灵活易用的Java绘图API,使用它可以生成多 ...

  7. Objective-C中的runtime的原理和用法

    一.runtime介绍 runtime翻译就是运行时,我们称为运行时机制.在OC中最重要的体现就是消息发送机制. 1)在C语言中,程序在编译过程中就决定调用哪个函数. 2)在OC中,编译的时候不会决定 ...

  8. zzuli oj 1178 单词数

    Description 统计一篇文章里不同单词的总数. Input 有多组数据,每组一行,每组就是一篇小文章.每篇小文章都是由小写字母和空格组成,没有标点符号,遇到#时表示输入结束. Output 每 ...

  9. URL传参中不能带特殊的字符以及处理方案

    有些符号在URL中是不能直接传递的,如果要在URL中传递这些特殊符号,那么就要使用他们的编码了.编码的格式为:%加字符的ASCII码,即一个百分号%,后面跟对应字符的ASCII(16进制)码值.例如 ...

  10. 【MS Office2013小技巧】Word中公式中的等号对齐

    步骤: 1. 先将所需要对齐的公式分不同行打出来: 2. 选中所有公式,右键点击并选择“对齐点(A) =”,如图 此时,如果能够正常对齐,则无需进行下面的步骤,但如果出现下图情况并未正常对齐的,再进行 ...