hiho week 255 register

Ended

Participants:127

Verdict:Accepted
Score:100 / 100
Submitted:2019-05-19 10:15:54

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<vector>
#include<string>
#include<unordered_map>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
int main() {
    int n;
    long long x,y;
    cin>>n;
    unordered_map<long long, long long> map[4];
    for(int i=0;i<n;++i){
        cin>>x>>y;
        if(map[0].find(x)==map[0].end()) map[0][x]=0;
        ++map[0][x];
        if(map[1].find(y)==map[1].end()) map[1][y]=0;
        ++map[1][y];
        if(map[2].find(y-x)==map[2].end()) map[2][y-x]=0;
        ++map[2][y-x];
        if(map[3].find(x+y)==map[3].end()) map[3][x+y]=0;
        ++map[3][x+y];
    }
    long long ans=0;
    for(int i=0;i<4;++i) {
        for(unordered_map<long long, long long>::iterator it=map[i].begin();it!=map[i].end();++it) {
            long long v=it->second;
            ans+=v*(v-1)/2;
        }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX