# Codeforces Round #341 Div.2 B. Wet Shark and Bishops

Source: Internet
Author: User

Test instructions: Bishop on the same diagonal (that's right. =) will attack each other and seek the logarithm of each other.

Since there are positive and negative diagonal lines, the X-y and x+y written by each bishop are saved with two arrays respectively.

And then scan each array for the repeating number k ans plus kC2 on the line.

WA took two rounds because it didn't take into account that if the entire array was duplicated, the last amount was added once.

`#include <cstdio>#include<cmath>#include<cstring>#include<queue>#include<vector>#include<algorithm>#defineINF 0x3f3f3f3f#defineMem (str,x) memset (str, (x), sizeof (str))#defineSTOP puts ("Pause");using namespaceStd;typedefLong LongLL;intN, node[200010], node2[200010]; LL ans;intMain () {ans=0; scanf ("%d", &N);  for(inti =1; I <= N; i++){        intx, y; scanf ("%d%d", &x, &y); Node[i]= X-y; Node2[i]= x +y; } Sort (Node+1, node +1+N); Sort (Node2+1, Node2 +1+N); LL Count=1;  for(inti =2; I <= N; i++){        if(Node[i] = = node[i-1]) count++; Else{ans+ = (count * (Count-1) /2); Count=1; }} ans+ = (count * (Count-1) /2); Count=1;  for(inti =2; I <= N; i++){        if(Node2[i] = = node2[i-1]) count++; Else{ans+ = (count * (Count-1) /2); Count=1; }} ans+ = (count * (Count-1) /2); printf ("%i64d\n", ans); return 0;}`

Codeforces Round #341 Div.2 B. Wet Shark and Bishops

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.