Cod sursa(job #2960896)

Utilizator bem.andreiIceman bem.andrei Data 5 ianuarie 2023 11:28:27
Problema Patrate 3 Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.9 kb
#include<bits/stdc++.h>

using namespace std;
ifstream r("patrate3.in");
ofstream w("patrate3.out");

int n, cnt=0;
long long dstx, dsty;
set<pair<int,int>>s;
pair<int,int>pereche1,pereche2;
int main()
{
    float x1,y1;
    r>>n;
    for(int i=0; i<n; ++i)
    {
        r>>x1>>y1;
        x1=round(x1*10000);
        y1=round(y1*10000);
        s.insert(make_pair(x1,y1));
    }
    for(auto x:s)
    {
        for(auto y:s)
        {
            if(x!=y)
            {
                dstx=x.second-y.second;
                dsty=y.first-x.first;
                pereche1=make_pair(dstx+x.first, dsty+x.second);
                pereche2=make_pair(dstx+y.first, dsty+y.second);
                if(s.find(pereche1)!=s.end() && s.find(pereche2)!=s.end())
                {
                    cnt++;
                }
            }
        }
    }
    w<<cnt/4;
    return 0;
}