题意:两点(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. 易买网(注册Ajax讲解)

    关于注册(用到Ajax) 运用onblur进行时时刷新 创建所需用的Servlet 好了 Ajax其实不是很难  如果还是不懂可以私信我呦-^^-!

  2. demo——06弹性和制作骰子

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  3. mac 生成支付宝的rsa公钥和私钥 php版本

    openssl genrsa -out rsa_private_key.pem 1024 公钥 openssl rsa -in rsa_private_key.pem -pubout -out rsa ...

  4. 更加直观地了解hasLayout和BFC

    网络上有很多关于hasLayout和BFC相关的文章,但是大部分都显得有些晦涩难懂.所以想用一些比较直观的例子来说明hasLayout和BFC给平时的布局带来的影响. 基础知识 在讲hasLayout ...

  5. 查看文章 mysql:表注释和字段注释[转]

    1 创建表的时候写注释 create table test1 ( field_name int comment '字段的注释' )comment='表的注释'; 2 修改表的注释 alter tabl ...

  6. python 函数1

    一.背景 在学习函数之前,一直遵循:面向过程编程,即:根据业务逻辑从上到下实现功能,其往往用一长段代码来实现指定功能,开发过程中最常见的操作就是粘贴复制,也就是将之前实现的代码块复制到现需功能处,如下 ...

  7. ios开发之C语言第3天

    变量的命名规则以及规范 变量的命名规则  1>变量名只能由任意的字母,下划线和$以及数字组成,注意不能用数字开头 2>区分大小写 3>变量一定要先定义再使用 4>同一个大括号中 ...

  8. U盘装系统出现错误 安装失败怎么办

    在用U盘装系统的时候,有些用户犹豫第一次操作,经常会遇到一些问题.例如U盘装系统失败;U盘容量已用完;内存损坏等种种问题.因此小编整理了一些关于U盘装系统失败的常见问题解答,希望对大家有帮助! 1. ...

  9. HTML DOM select() 方法

    定义和用法 select() 方法用于选择该元素中的文本. 语法 textareaObject.select() 实例 下面的例子可选择文本框中的文本: <html> <head&g ...

  10. CSAPP(深入理解计算机系统)读后感

    9月到10月8号,包括国庆七天,大概每天5小时以上的时间,把Computer System: A Programmer Perspective 2rd version(深入理解计算机系统)的英文版啃完 ...