Cod sursa(job #2768744)

Utilizator valentinchipuc123Valentin Chipuc valentinchipuc123 Data 12 august 2021 02:28:51
Problema Patrate 3 Scor 100
Compilator cpp-64 Status done
Runda Teme Pregatire ACM Unibuc 2013 Marime 0.82 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=points.begin();j!=points.end();j++)
    {
        if(i!=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/4;

    return 0;
}