Cod sursa(job #2770089)

Utilizator valentinchipuc123Valentin Chipuc valentinchipuc123 Data 19 august 2021 12:49:26
Problema Patrate 3 Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ifstream fin("patrate3.in");
    ofstream fout("patrate3.out");
    set<pair<int, int>> points;
    int n;
    fin >> n;
    double x, y;
    for(int i = 0; i < n; i++)
    {
        fin >> x >> y;
        points.insert(make_pair(round(x * 10000), round(y * 10000)));
    }
    int nr = 0;
    int x3, x4, y3, y4;
    for(auto i = points.begin(); i != points.end(); ++i)
        for(auto j = next(i); j != points.end(); ++j)
            ///for(auto j = next(i,1); j != points.end(); ++j)
        {
            x3 = i->second - j->second + j->first;
            y3 = j->first - i->first + j->second;
            x4 = i->second - j->second + i->first;
            y4 = j->first - i->first + i->second;
            if(points.find({x3, y3}) != points.end() && points.find({x4, y4}) != points.end())
                nr++;
        }
    fout << nr / 2;
    return 0;
}