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 ...
随机推荐
- js设置全局变量ajax中赋值
js设置全局变量,在ajax中给予赋值赋值不上问题解决方案 方案一. //在全局或某个需要的函数内设置Ajax异步为false,也就是同步. $.ajaxSetup({async : false}); ...
- Stammering Aliens
Stammering Aliens Time Limit: 2000MS Memory Limit: 65536K Description Dr. Ellie Arroway has ...
- Got Stucked in C++ Static Library Loading.. for some time
I used to load library using 1 single .dll file, so when I happen to do method calling between 2 pro ...
- char与varchar、nvarchar区别
char char是定长的,也就是当你输入的字符小于你指定的数目时,char(8),你输入的字符小于8时,它会再后面补空值.当你输入的字符大于指定的数时,它会截取超出的字符. nvarc ...
- php实现echo json_encode正确显示汉字
<?php header('Content-type: text/html; charset=utf-8'); /* function showmessage($msg = '', $redir ...
- 【Python初学】深copy&浅copy
在python中,对象赋值实际上是对象的引用.当创建一个对象,然后把它赋给另一个变量的时候,python并没有拷贝这个对象,而只是拷贝了这个对象的引用. 1. copy.copy 浅拷贝 只拷贝父对象 ...
- 在Activity之间使用Intent传值和Bundle传值的区别和方式
两者本质上没有任何区别.Bundle只是一个信息的载体 将内部的内容以键值对组织 Intent负责Activity之间的交互 自己是带有一个Bundle的Intent.putExtras(Bundle ...
- c语言scanf详解
函数名: scanf 功 能: 执行格式化输入 用 法: int scanf(char *format[,argument,...]);scanf()函数是通用终端格式化输入函数,它从标准输入设备(键 ...
- Oracle Sql优化之范围处理
1.表中字段自关联与分析函数的性能比较,自关联需要扫描表两次,分析函数扫描一次即可 ----自关联 select v1.proj_id,v1.proj_start,v1.proj_end from v ...
- JavaScript判断数组是否存在key
JS中复合数组associative array和对象是等同的,判断一个key是否存在于数组中(或对象是否包含某个属性),不能使用ary[key] == undefined,因为可能存在ary = { ...