Cod sursa(job #3309077)

Utilizator Mateixx1Trandafir Matei Mateixx1 Data 31 august 2025 20:35:36
Problema Patrate 3 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.96 kb
#include <iostream>
#include <cmath>
#include <fstream>
#include <set>
using namespace std;
ifstream f("triang.in");
ofstream g("triang.out");
const double EPS=1e-4;
int n,rez;

struct punct {
    double x,y;
} p[1510];

struct cmp {
    bool operator()(const punct &a,const punct &b) const {
        if(abs(a.x-b.x)>EPS) {
            return a.x<b.x;
        }
        if(abs(a.y-b.y)>EPS) {
            return a.y<b.y;
        }
        return 0;
    }
};

set<punct,cmp>da;

int main() {
    f>>n;
    for(int i=1; i<=n; i++) {
        f>>p[i].x>>p[i].y;
        for(int j=1; j<i; j++) {
            double pozx=(p[j].x-p[i].x)*0.5-(p[j].y-p[i].y)*sqrt(3)/2.0+p[i].x;
            double pozy=(p[j].x-p[i].x)*sqrt(3)/2.0+(p[j].y-p[i].y)*0.5+p[i].y;
            if(da.find({pozx,pozy})!=da.end()) {
                rez++;
            }
        }
        da.insert(p[i]);
    }
    g<<rez;
    f.close();
    g.close();
    return 0;
}