题意:处在同一对角线上的主教(是这么翻译没错吧= =)会相互攻击 求互相攻击对数

由于有正负对角线 因此用两个数组分别保存每个主教写的 x-y 和 x+y

然后每个数组中扫描重复数字k ans加上kC2就行了

wa了两发的原因是没考虑到如果整个数组都是重复的 那要最后额外加一次

#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
#define INF 0x3f3f3f3f
#define mem(str,x) memset(str,(x),sizeof(str))
#define STOP puts("Pause");
using namespace std;
typedef long long LL; int n, node[], node2[];
LL ans; int main()
{
ans = ;
scanf("%d", &n);
for(int i = ; i <= n; i++){
int x, y;
scanf("%d%d", &x, &y);
node[i] = x - y;
node2[i] = x + y;
}
sort(node + , node + + n);
sort(node2 + , node2 + + n);
LL count = ;
for(int i = ; i <= n; i++){
if(node[i] == node[i-]) count++;
else{
ans += (count * (count - ) / );
count = ;
}
}
ans += (count * (count - ) / );
count = ;
for(int i = ; i <= n; i++){
if(node2[i] == node2[i-]) count++;
else{
ans += (count * (count - ) / );
count = ;
}
}
ans += (count * (count - ) / );
printf("%I64d\n", ans);
return ;
}

Codeforces Round #341 Div.2 B. Wet Shark and Bishops的更多相关文章

  1. Codeforces Round #341 (Div. 2) E. Wet Shark and Blocks dp+矩阵加速

    题目链接: http://codeforces.com/problemset/problem/621/E E. Wet Shark and Blocks time limit per test2 se ...

  2. Codeforces Round #341 Div.2 C. Wet Shark and Flowers

    题意: 不概括了..太长了.. 额第一次做这种问题 算是概率dp吗? 保存前缀项中第一个和最后一个的概率 然后每添加新的一项 就解除前缀和第一项和最后一项的关系 并添加新的一项和保存的两项的关系 这里 ...

  3. Codeforces Round #341 Div.2 A. Wet Shark and Odd and Even

    题意是得到最大的偶数和 解决办法很简单 排个序 取和 如果是奇数就减去最小的奇数 #include <cstdio> #include <cmath> #include < ...

  4. Codeforces Round #341 (Div. 2) E - Wet Shark and Blocks

    题目大意:有m (m<=1e9) 个相同的块,每个块里边有n个数,每个数的范围是1-9,从每个块里边取出来一个数组成一个数,让你求组成的方案中 被x取模后,值为k的方案数.(1<=k< ...

  5. Codeforces Round #341 (Div. 2)

    在家都变的懒惰了,好久没写题解了,补补CF 模拟 A - Wet Shark and Odd and Even #include <bits/stdc++.h> typedef long ...

  6. Codeforces Round #341 (Div. 2) ABCDE

    http://www.cnblogs.com/wenruo/p/5176375.html A. Wet Shark and Odd and Even 题意:输入n个数,选择其中任意个数,使和最大且为奇 ...

  7. Codeforces Round #341 (Div. 2)B

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

  8. Codeforces Round #341 (Div. 2) D. Rat Kwesh and Cheese 数学

    D. Rat Kwesh and Cheese 题目连接: http://www.codeforces.com/contest/621/problem/D Description Wet Shark ...

  9. Codeforces Round #341 (Div. 2)A

    A. Wet Shark and Odd and Even time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

随机推荐

  1. 作业七:团队项目——Alpha版本冲刺阶段002

    今日进展:我们终于安装好了软件,今天开始进行作业设计. 今日安排:今天开始我们要开始我们的框架的设计.

  2. EF快速开发定义数据接口类(转)

    using System; using System.Linq; using System.Linq.Expressions; using System.Data.Objects; namespace ...

  3. JS 笔记(二) - 函数

    1. 函数的 声明 1) 声明式写法 function j1(id){ alert(id); } 2) 声明匿名函数变量 var j2 = function (a, b) { alert(a + &q ...

  4. MySQL5.6下使用xtrabackup部分备份恢复到MySQL5.7

    现有需求:需要备份MySQL5.6环境下的部分表到MySQL5.7环境下并进行恢复 通过xtrabackup 实现部分备份有三种方式: 参考链接:http://blog.csdn.net/zhu197 ...

  5. NSLOG打印不全的问题

    #ifdef DEBUG #define NSLog(FORMAT, ...) fprintf(stderr, "%s:%zd\t%s\n", [[[NSString string ...

  6. RCurl网络数据抓取

    观察基础信息(服务器信息和提交给服务器的信息) d=debugGatherer()xpath="http://123.sogou.com/"url=getURL(xpath,deb ...

  7. sql的列的说明

    <#@ template debug="true" hostspecific="true" language="C#" #> & ...

  8. Cardinal样条曲线的Javascript实现(理论篇)

    首先,要对样条曲线进行插值的原因是:希望通过给定的关键帧点生成一条希望的直线或者曲线. 1.直线插值 生成一条直线,给定直线首尾的关键点P0,P1,就能确定这条直线的特性,比如y=kx+b中的斜率k和 ...

  9. Selenium 2 入门

    在多个浏览器中进行 Web 应用程序的端到端功能测试 Selenium 是一款有名的 Web 应用程序测试框架,用于进行功能测试.新版本 Selenium 2 结合了 Selenium 1 和 Web ...

  10. Mac小知识(不定时更新)

    1.显示隐藏文件夹(在mac命令行中输入以下代码即可): 1)显示隐藏文件夹 defaults write com.apple.finder AppleShowAllFiles Yes &&a ...