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 ...
随机推荐
- 关于WIFI DIRECT功能的
http://processors.wiki.ti.com/index.php/WiFi_Direct_Configuration_Scripts#p2p_find https://wire ...
- OC中的野指针,空指针,nil,Nil,NULL,NSNULL小结
周末与一个老朋友吃饭聊天,因为他正在培训班学习iOS开发,就随便聊了几句,发现自己OC基础上的欠缺和一些知识点的混淆.特此整理如下. 1.空指针 没有存储任何内存地址的指针就称为空指针(NULL指针) ...
- cell reuse & disposebag
For my project I've made base cell class TableViewCell: UITableViewCell { private(set) var disposeBa ...
- 默认系统为UEFI启动的GPT分区的WIN7(8),如何安装VHD的UEFI WIN8(7)
默认系统为UEFI启动的GPT分区的WIN7(8),如何安装VHD的UEFI WIN8(7) 情况A:如果默认系统为UEFI启动.GPT分区的WIN7,想安装个VHD的UEFI WIN8.1 1:系统 ...
- IDA_Python命令行使用
Python>import idaapi Python>hex(idaapi.get_first_cref_from(here()))
- Android Studio 提示Error running app: No Android facet found for app
错误解决办法如下: 可以通过以下几个步骤解决该问题: 1) 点击菜单File -> 选择Project Structure, 或使用快捷键 (Ctrl+Alt+Shift+S) 打开”Proje ...
- hdu_3564_Another LIS(线段树+LIS)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3564 题意:给你N个数的位置.数i的位置为第i个数,比如 0 0 2,表示1插在第0个位置,此时数列为 ...
- html input密码显示为“*”
1. 功能需求:HTML中,在input password输入框中输入字符将默认显示为“实体圆点”,但这里要求将实体圆点字符替换成“*”号显示. 2. 局限:鼠标光标非IE浏览器不一定显示,选择多个字 ...
- HDU 1204 基础DP 非连续字段的最大和
其实这个感觉是一眼题,只不过我真心太菜了. 题目已经告诉你了,有m段,n个数字,那么我们就只需要dp[m][n]即可,然后最后的答案肯定是dp[m][]的那一行,所以其他行都是没有用的,因为我们可以把 ...
- PL/SQL developer 管理多套数据库
PL/SQL developer 管理多套数据库,作为一个统一的接口平台,连接多套数据库. 1.. 1.类SQL PLUS窗口:File->New->Command Window,这个类似 ...