Cod sursa(job #2798871)

Utilizator VladPislaruPislaru Vlad Rares VladPislaru Data 12 noiembrie 2021 00:13:14
Problema Patrate 3 Scor 95
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.09 kb
#include <bits/stdc++.h>

using namespace std;

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

set <pair<int, int>> M;
pair <int, int> a[10005];

int main()
{
    int n, cnt = 0;
    fin >> n;
    for (int i = 1; i <= n; i++)
    {
        double x , y;
        fin >> x >> y;
        int int_x = round(x * 10000);
        int int_y = round(y * 10000);
        a[i] = {int_x, int_y};
        M.insert({int_x, int_y});
    }
    for (auto i = 1; i <= n; i++)
        for (auto j = 1; j <= n; j++)
        {
            if (i != j)
            {
                pair <int,int> C, D;
                C = D = {0 , 0};
                C.first = a[i].first + (a[i].second - a[j].second);
                C.second = a[i].second + (a[j].first - a[i].first);
                D.first = a[j].first + (a[i].second - a[j].second);
                D.second = a[j].second + (a[j].first - a[i].first);
                if (M.find (C) != M.end () && M.find (D) != M.end ())
                    cnt++;

            }
        }
    fout << cnt / 4 << "\n";
    return 0;
}