Cod sursa(job #2876369)

Utilizator BlueLuca888Girbovan Robert Luca BlueLuca888 Data 23 martie 2022 11:13:22
Problema Trapez Scor 0
Compilator cpp-64 Status done
Runda masonii Marime 0.66 kb
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")

using namespace std;

ifstream fin  ("trapez.in");
ofstream fout ("trapez.out");

int full_ox, full_oy;
int n, x, y;
unordered_map <int, bool> map_ox, map_oy;

int main (){
    ios_base::sync_with_stdio(false);
    fin.tie(nullptr);
    fout.tie(nullptr);

    fin>>n;
    while(n--){
        fin>>x>>y;
        if(map_ox[x] == false)
            map_ox[x] = true;
        else
            full_ox++;

        if(map_oy[y] == false)
            map_oy[y] = true;
        else
            full_oy++;
    }
    fout<<full_ox * (full_ox-1) / 2 + full_oy * (full_oy-1) / 2;
    return 0;
}