Cod sursa(job #2716504)

Utilizator Alex_tz307Lorintz Alexandru Alex_tz307 Data 5 martie 2021 11:49:04
Problema Patrate 3 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <bits/stdc++.h>

using namespace std;
using ld = long double;

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

const int NMAX = 1024;
int N;
pair<int,int> a[NMAX];

bool check(const int &i, const int &j) {
    return binary_search(a, a + N, make_pair(a[i].first, a[j].second)) && binary_search(a, a + N, make_pair(a[j].first, a[i].second));
}

int main() {
    fin >> N;
    for(int i = 0; i < N; ++i) {
        ld x, y;
        fin >> x >> y;
        a[i].first = round(x * 10000);
        a[i].second = round(y * 10000);
    }
    sort(a, a + N);
    int ans = 0;
    for(int i = 0; i < N; ++i)
        for(int j = 0; j < N; ++j)
            ans += check(i, j);
    fout << ans / 4 << '\n';
}