Cod sursa(job #3309426)

Utilizator StefanRaresStefan Rares StefanRares Data 4 septembrie 2025 15:09:06
Problema Triang Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.02 kb
#include <iostream>
#include <fstream>
#include <cmath>
#include <set>
using namespace std;
ifstream f("triang.in");
ofstream g("triang.out");
const double EPS = 1e-4;
struct punct
{
    double x, y;
}v[1501];
struct comp
{
    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, comp> S;
int n, cnt;
punct rotire(const punct &a, const punct &b)
{
    punct c;
    double sin60 = sqrt(3) / 2.0,
           cos60 = 0.5;
    c.x = a.x + (b.x - a.x) * cos60 - (b.y - a.y) * sin60;
    c.y = a.y + (b.x - a.x) * sin60 + (b.y - a.y) * cos60;
    return c;
}
int main()
{
    f >> n;
    for(int i = 1; i <= n; i++)
    {
        f >> v[i].x >> v[i].y;
        for(int j = 1; j < i; j++)
            if(S.find(rotire(v[i], v[j])) != S.end())
                cnt++;
        S.insert(v[i]);
    }
    g << cnt;
    f.close();
    g.close();
    return 0;
}