Cod sursa(job #2755319)

Utilizator bestman4111Tiberiu Niculae bestman4111 Data 26 mai 2021 23:33:59
Problema Patrate 3 Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.11 kb
#include<iostream>
#include<fstream>
#include<set>
#include<cmath>
using namespace std;

ifstream cit("patrate3.in");
ofstream afis("patrate3.out");

int main()
{
    set<pair<int, int>> puncte;
    pair<int, int> vec[1001];
    int N, patrate = 0;
    double x, y;

    cit>>N;
    for(int i = 0; i < N; i++){
        cit>>x>>y;
        vec[i].first = round(x * 10000);
        vec[i].second = round(y * 10000);
        puncte.insert(vec[i]);
    }

    int x1, x2, x3, x4, y1, y2, y3, y4;

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i != j){
                x1 = vec[i].first;
                y1 = vec[i].second;
                x2 = vec[j].first;
                y2 = vec[j].second;

                x3 = y1 - y2 + x2;
                y3 = x2 - x1 + y2;
                x4 = y1 - y2 + x1;
                y4 = x2 - x1 + y1;

                if((puncte.find({x3, y3}) != puncte.end()) && (puncte.find({x4, y4}) != puncte.end())){
                    patrate++;
                }
            }
        }
    }
    afis<<patrate/4;
    return 0;
}