对角线 x1+y1=x2+y2 或者x1-y1=x2-y2

 #include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
#define clc(a,b) memset(a,b,sizeof(a))
const int maxn=; int main()
{
int n;
int x,y;
int a[maxn];
int b[maxn];
scanf("%d",&n);
clc(a,);
clc(b,);
for(int i=;i<n;i++)
{
scanf("%d%d",&x,&y);
a[x+y]++;
b[x-y+]++;
}
ll sum=;
for(int i=;i<=;i++)
{
if(a[i]%)
sum+=(a[i]-)/*a[i];
else
sum+=a[i]/*(a[i]-);
}
for(int i=-+;i<=+;i++)
{
if(b[i]%)
sum+=(b[i]-)/*b[i];
else
sum+=b[i]/*(b[i]-);
}
printf("%I64d\n",sum);
return ;
}

codeforce 621B Wet Shark and Bishops的更多相关文章

  1. CodeForces 621B Wet Shark and Bishops

    记录一下每个对角线上有几个,然后就可以算了 #include<cstdio> #include<cstring> #include<cmath> #include& ...

  2. B. Wet Shark and Bishops(思维)

    B. Wet Shark and Bishops time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  3. Codeforces 612B. Wet Shark and Bishops 模拟

    B. Wet Shark and Bishops time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...

  4. Wet Shark and Bishops(思维)

    Today, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are nu ...

  5. 【CodeForces 621B】Wet Shark and Bishops

    题 题意 1000*1000的格子里,给你n≤200 000个点的坐标,求有多少对在一个对角线上. 分析 如果求每个点有几个共对角线的点,会超时. 考虑到对角线总共就主对角线1999条+副对角线199 ...

  6. Codeforces Round #341 Div.2 B. Wet Shark and Bishops

    题意:处在同一对角线上的主教(是这么翻译没错吧= =)会相互攻击 求互相攻击对数 由于有正负对角线 因此用两个数组分别保存每个主教写的 x-y 和 x+y 然后每个数组中扫描重复数字k ans加上kC ...

  7. codeforce 621C Wet Shark and Flowers

    题意:输入个n和质数p,n个区间,每个区间可以等概率的任选一个数,如果选的这个区间和它下个区间选的数的积是p的倍数的话(n的下个是1),就挣2000,问挣的期望 思路:整体的期望可以分成每对之间的期望 ...

  8. codeforce 621A Wet Shark and Odd and Even

    水 最大偶数和 #include<iostream> #include<string> #include<algorithm> #include<cstdli ...

  9. Chocolate&&木块拼接&&Cards&& Wet Shark and Bishops

    B. Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

随机推荐

  1. vim emmet配置

    http://nerd-is.in/2013-12/learning-vim-again-1-install-vundle/ http://nerd-is.in/2013-12/learn-vim-a ...

  2. Sublime Text 3插件之SublimeTmpl:新建文件的模版插件

    SublimeTmpl能新建html.css.javascript.php.python.ruby六种类型的文件模板,所有的文件模板都在插件目录的templates文件夹里,可以自定义编辑文件模板. ...

  3. git reflog 和git log :no branch git 提交方式

    git reflog 和git log的区别,外加git cherry-pick的一种用法 git reflog 可以查看所有分支的所有操作记录(包括(包括commit和reset的操作),包括已经被 ...

  4. 通知NSNotificationCenter

    注意:接受通知要写在 viewDidLoad 方法里面 取得系统全局的唯一广播站 NSNotificationCenter *notification = [NSNotificationCenter  ...

  5. CODEVS 1069关押罪犯

    题目描述 Description S 城现有两座监狱,一共关押着N 名罪犯,编号分别为1~N.他们之间的关系自然也极 不和谐.很多罪犯之间甚至积怨已久,如果客观条件具备则随时可能爆发冲突.我们用“怨 ...

  6. List<>过滤重复的简单方法

    List<int> ss = new List<int>(); ss.Add(); ss.Add(); ss.Add(); ss.Add(); ss.Add(); ss.Add ...

  7. 解决ubuntu无法调整和保存屏幕亮度的问题

    整理自解决ubuntu无法调整和保存屏幕亮度的问题 ubuntu无法调整屏幕亮度,对笔记本来说很耗电,同时也很刺眼,因为它是默认以最大亮度来工作的. 所谓的调整,方法为下面的其中一种: 1.Fn+左右 ...

  8. 实用make最佳实践

    http://www.cnblogs.com/ggjucheng/archive/2011/12/14/2288055.html 一.前言 Make工具最主要也是最基本的功能就是通过makefile文 ...

  9. SQL中Case的使用方法(下篇)(转)

    接上篇 四,根据条件有选择的UPDATE. 例,有如下更新条件 工资5000以上的职员,工资减少10% 工资在2000到4600之间的职员,工资增加15% 很容易考虑的是选择执行两次UPDATE语句, ...

  10. Hibernate 一对多自身双向关联关系 用于类别表的实现

    分类:一对多自身双向关联关系 Java持久化类: package com.hyy.hibernate.one_to_many.domain; import java.util.HashSet; imp ...