记录一下每个对角线上有几个,然后就可以算了

#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#include<vector>
#include<algorithm>
using namespace std; const int maxn=+;
int n;
long long w1[maxn];
long long w2[maxn];
long long ans; int main()
{
int n;
scanf("%d",&n);
ans=;
memset(w1,,sizeof w1);
memset(w2,,sizeof w2); for(int i=; i<=n; i++)
{
int x,y;
scanf("%d%d",&x,&y);
int p=; p=p+(x-);
p=p-(y-); w1[p]++; p=;
p=p+x-;
p=p-(-y);
w2[p]++;
} for(int i=; i<=; i++)
if(w1[i]!=&&w1[i]!=)
ans=ans+(w1[i]-)*w1[i]/; for(int i=; i<=; i++)
if(w2[i]!=&&w2[i]!=)
ans=ans+(w2[i]-)*w2[i]/; printf("%lld\n",ans); return ;
}

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

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

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

  2. codeforce 621B Wet Shark and Bishops

    对角线 x1+y1=x2+y2 或者x1-y1=x2-y2 #include<iostream> #include<string> #include<algorithm& ...

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

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

  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. 【矩阵乘法优化dp】[Codeforces 621E] Wet Shark and Blocks

    http://codeforces.com/problemset/problem/621/E E. Wet Shark and Blocks time limit per test 2 seconds ...

  6. CODEFORCEs 621E. Wet Shark and Blocks

    E. Wet Shark and Blocks time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  7. 【CodeForces 621B】Wet Shark and Bishops

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

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

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

  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. 使用SQL Server Management Studio 创建作业备份数据库

    在项目中,经常需要备份数据库,如果能做到只需点个按钮(“开始备份数据库”按钮),然后什么都不管,数据库就自动备份好了,或者服务器上的数据库隔一段时间自动备份一次,那该多好啊. Sql server 的 ...

  2. NoSql的产生

    主流的关系型数据库:Microsoft SQLServer, IBM DB2, Oracle, MySQL, Microsoft Access, Sybase,IBM Informix 随着互联网we ...

  3. JPA 系列教程7-双向多对多

    双向多对多的ddl语句 同单向多对多表的ddl语句一致 Student package com.jege.jpa.many2many; import java.util.HashSet; import ...

  4. scrollview上面的图片不上下滑动

    self.automaticallyAdjustsScrollViewInsets= NO;

  5. JDBC的超时原理

    1.什么是JDBC jdbc是业务系统连接数据的标准API.SUN公司一共定义了4中类型的JDBC:JDBC-ODBC桥:Native-API 驱动:Network-Protocol 驱动:Datab ...

  6. 一个设置 material design icon的插件工具

    一个设置 material design icon的插件工具 github地址:https://github.com/konifar/android-material-design-icon-gene ...

  7. Mysql笔记4数据表操作1

    1查看表的结构 (1)show create table +数据库名称 (2)desc+数据库名称 2修改表 (1)表中添加列 alter table 数据库名称 add column addr va ...

  8. Windows API 之 FineFirstFile、FindNextFile

    参考:https://msdn.microsoft.com/en-us/library/aa364418%28VS.85%29.aspx FindFirstFile Searches a direct ...

  9. 微信小程序实例教程(一)

    序言 开始开发应用号之前,先看看官方公布的「小程序」教程吧!(以下内容来自微信官方公布的「小程序」开发指南) 本文档将带你一步步创建完成一个微信小程序,并可以在手机上体验该小程序的实际效果.这个小程序 ...

  10. parseInt(),parseFloat(),parse()

    1.parseInt() 该函数将变量转换为整型数.只有对字符串型的数据调用该函数才有意义,其他类型如果使用parseInt()函数,则会返回NaN. 2.parseFloat() 该函数和parse ...