Cod sursa(job #3288259)

Utilizator Mihai_OctMihai Octavian Mihai_Oct Data 21 martie 2025 09:22:58
Problema Triang Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.04 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("triang.in");
ofstream fout("triang.out");
const double sin60 = sqrt(3) / 2.0;
const double cos60 = 1 / 2.0;
const double eroare = 1e-3;
struct Punct {
    double x, y;

    bool operator<(const Punct& p) const {
        if(abs(x - p.x) > eroare) return x < p.x;
        if(abs(y - p.y) > eroare) return y > p.y;
        return false;
    }
} p[1502];
set<Punct> fr;
int n, i, j, rasp;

static inline double GetXPunct(Punct a, Punct b) {
    return a.x + cos60 * (b.x - a.x) - sin60 * (b.y - a.y);
}

static inline double GetYPunct(Punct a, Punct b) {
    return a.y + sin60 * (b.x - a.x) + cos60 * (b.y - a.y);
}

int main() {
    fin >> n;
    for(i = 1; i <= n; i++) {
        fin >> p[i].x >> p[i].y;
        for(j = 1; j < i; j++) {
            double xCur = GetXPunct(p[i], p[j]);
            double yCur = GetYPunct(p[i], p[j]);

            if(fr.count({xCur, yCur})) rasp++;
        }
        fr.insert(p[i]);
    }
    fout << rasp;

    return 0;
}