CodeForces 621B Wet Shark and Bishops
记录一下每个对角线上有几个,然后就可以算了
#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的更多相关文章
- Codeforces 612B. Wet Shark and Bishops 模拟
B. Wet Shark and Bishops time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...
- codeforce 621B Wet Shark and Bishops
对角线 x1+y1=x2+y2 或者x1-y1=x2-y2 #include<iostream> #include<string> #include<algorithm& ...
- B. Wet Shark and Bishops(思维)
B. Wet Shark and Bishops time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- 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 ...
- 【矩阵乘法优化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 ...
- 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 ...
- 【CodeForces 621B】Wet Shark and Bishops
题 题意 1000*1000的格子里,给你n≤200 000个点的坐标,求有多少对在一个对角线上. 分析 如果求每个点有几个共对角线的点,会超时. 考虑到对角线总共就主对角线1999条+副对角线199 ...
- Codeforces Round #341 Div.2 B. Wet Shark and Bishops
题意:处在同一对角线上的主教(是这么翻译没错吧= =)会相互攻击 求互相攻击对数 由于有正负对角线 因此用两个数组分别保存每个主教写的 x-y 和 x+y 然后每个数组中扫描重复数字k ans加上kC ...
- Chocolate&&木块拼接&&Cards&& Wet Shark and Bishops
B. Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
随机推荐
- linux sigaction信号处理
sigaction函数相比signal函数更为复杂,但更具灵活性,下面具体介绍她的结构和用法: #include <signal.h> int sigaction(int signum, ...
- 不同版本(2.3,2.4,2.5) web.xml 的web-app头信息
原址:点击打开链接 Servlet 2.3 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE w ...
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级,-fomit-frame-pointer
英文:https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Optimize-Options.html#Optimize-Options 少优化->多优化: ...
- dl以及dt,dd,以及table的tr,th,td最清楚分析
1,定义:<dl> <dt> <dd>是一组合标签,使用了dt dd最外层就必须使用dl包裹,此组合标签我们也又叫表格标签,与table表格类似组合标签,故名我们也 ...
- UVALive 7291 Kinfolk(最近公共祖先)
题目中的描述就很最近公共祖先,再说其实这个题并不难,就是麻烦点(代码其实可以化简的),我写的判定比较多. 方法:求出两者的最近公共祖先lca,在求出两者到lca的距离 分析:给出a和b,如果LCA(a ...
- Ubuntu安装Anaconda3
下载 https://www.continuum.io/downloads#_unix Python3.5 Linux 32-bit 安装 bash Anaconda3-2.4.0-Linux-x8 ...
- mysql 索引相关
引言: MYSQL由于其免费和开源的性质,在项目中用处广泛.大家都知道,一个MySQL数据库能够储存大量的数据,如果要在大量的数据中查找某一个数据,如果使用全表检索的话,即费时间又费力气,这时,就需要 ...
- ViewHolder最简洁的写法
通用viewHolder工具类: public class ViewHolder { // I added a generic return type to reduce the casting no ...
- 设置自己Eclipse代码风格(内部)
http://www.cnblogs.com/farseer810/p/4391318.html 经过这几次的代码提交,发现很多人的代码风格不够规范.个人认为很有必要强制性规定一下代码的规范. 整体来 ...
- jpda
http://www.ibm.com/developerworks/cn/java/j-lo-jpda1/ 远程调试用rmi通信,被调试端需要启动一个调试服务器,用命令jsadebugd. java/ ...