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 ...
随机推荐
- curl 测试web站点的响应时间
curl -s -w "\n"::%{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total} ...
- 【转】How to build and install PHP 5.6.9 from source on Ubuntu 14.04 VPS
原文 https://vpsineu.com/blog/how-to-build-and-install-php-5-6-9-from-source-on-ubuntu-14-04-vps/ In t ...
- 【字母全排列】 poj 1256
深搜 注意与STL模版的去重函数唯一的区别就是有去重. #include <iostream> #include <cstdio> #include <string. ...
- idea编译报错:未结束的字符串文字;非法的表达式;未结束的字符串字面值
在idea的Settings中,找到File Encodings,将IDE Encoding 改为UTF-8 要多试几次,清除缓存什么的,具体原因不知道,不过经常第一次修改不能成功.
- linux的学习系列 3---目录
目录也是一个文件,它的唯一功能是用来保存文件及其相关信息.所有的文件,包括普通文件.设备文件和目录文件,都会被保存到目录中. 主目录 登录后,你所在的位置就是你的主目录(或登录目录),接下来你主要是在 ...
- Jmeter的优点是什么?除了轻量级,它和LoadRunner有什么本质区别
1.jmeter的架构和loadrunner原理一样,都是通过中间代理,监控和收集并发客户端发出的指令,把他们生成脚本,再发送到应用服务器,再监控服务器反馈结果的一个过程: 2.分布式中间代理功能在j ...
- js框架——angular.js(5)
1. 3种过滤方式 <html> <head> <meta charset='utf-8'> <script src="js/angular.js& ...
- LightOJ 1370 Bi-shoe and Phi-shoe(欧拉函数)
题意:题目给出一个欧拉函数值F(X),让我们求>=这个函数值的最小数N,使得F(N) >= F(X); 分析:这个题目有两种做法.第一种,暴力打出欧拉函数表,然后将它调整成有序的,再建立一 ...
- POJ 1523 SPF (去掉割点能形成联通块的个数)
思路:使用tarjan算法求出割点,在枚举去掉每一个割点所能形成的联通块的个数. 注意:后来我看了下别的代码,发现我的枚举割点的方式是比较蠢的方式,我们完全可以在tarjan过程中把答案求出来,引入一 ...
- js基础之数据类型
一:JavaScript 数据类型:字符串.数字.布尔.数组.对象.Null.Undefined JavaScript 字符串; var carname="Bill Gates ...