codeforces Codeforces 650A Watchmen
题意:两点(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的更多相关文章
- Codeforces Codeforces Round #484 (Div. 2) E. Billiard
Codeforces Codeforces Round #484 (Div. 2) E. Billiard 题目连接: http://codeforces.com/contest/982/proble ...
- Codeforces Codeforces Round #484 (Div. 2) D. Shark
Codeforces Codeforces Round #484 (Div. 2) D. Shark 题目连接: http://codeforces.com/contest/982/problem/D ...
- (水题)Codeforces - 650A - Watchmen
http://codeforces.com/contest/650/problem/A 一开始想了很久都没有考虑到重复点的影响,解欧拉距离和曼哈顿距离相等可以得到 $x_i=x_j$ 或 $y_i=y ...
- Codeforces 650A Watchmen
传送门 time limit per test 3 seconds memory limit per test 256 megabytes input standard input output st ...
- CodeForces 651 C Watchmen
C. Watchmen time limit per test 3 seconds memory limit per test 256 megabytes input standard input o ...
- codeforces 650 C. Watchmen(数学公式)
C. Watchmen time limit per test 3 seconds memory limit per test 256 megabytes input standard input o ...
- 【CodeForces - 651C 】Watchmen(map)
Watchmen 直接上中文 Descriptions: 钟表匠们的好基友马医生和蛋蛋现在要执行拯救表匠们的任务.在平面内一共有n个表匠,第i个表匠的位置为(xi, yi). 他们需要安排一个任务计划 ...
- 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 ...
- Codeforces Codeforces Round #316 (Div. 2) C. Replacement 线段树
C. ReplacementTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/problem ...
随机推荐
- js清空前后空格
function trim(sValue){ var lastValue=this.replace(/(^\s*)|(\s*$)/g,""); ...
- Fedora 17 修改GRUB启动菜单顺序
Fedora 16采用GRUB2,因此启动菜单编辑方式与以前版本有所不同 设置默认启动Windows 1. 首先找到Windows的menuentry # cat /boot/grub2/grub ...
- MongoDB3.2版本与3.0版本写场景压力测试对比
我们主要是为了测试journal对写操作性能的影响.分别测试了3.2版本,3.0版本在ramdisk,hdd上有journal,和没journal的情况. 发现一个很怪异的现象,3.2版本时候,随着y ...
- lamp环境-编译安装
http://my.oschina.net/JerryBaby/blog/292731 http://blog.chinaunix.net/uid-20639775-id-154442.html ht ...
- 如何彻底删除PPA软件库
添加一个PPA源 sudo add-apt-repository ppa:user/ppa-name 如添加cairo-dock到weekly update源 sudo add-apt-reposit ...
- C语言-06复杂数据类型-02字符串
#include <stdio.h> int main() { //char name[] = {'i', 't', 'c', 'H', 's', 't', '\0'}; char nam ...
- C语言-03流程控制
1.选择结构 char c = '+'; ; ; // 如果要在case后面定义新的变量,必须用大括号{}包住 注意变量的作用域的紊乱 if语句不加括号时,也要注意此问题 switch (c) { c ...
- 配置mybatis错误总结
### The error may exist in SQL Mapper Configuration ### Cause: org.apache.ibatis.builder.BuilderExce ...
- SQL Server强制删除复制发布
原文地址:http://blog.csdn.net/leamonjxl/article/details/7352208 SQL Server 中 存在以前(系统还原前)的发布内容,使用鼠标->右 ...
- BZOJ 1629: [Usaco2007 Demo]Cow Acrobats
Description Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away a ...