Cod sursa(job #3233083)

Utilizator Mihai_999Diaconeasa Mihai Mihai_999 Data 2 iunie 2024 13:47:04
Problema Triang Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.02 kb
#include <iostream>
#include <fstream>
#include <set>
#include <cmath>
#define nl '\n'

using namespace std;

ifstream fin("triang.in");
ofstream fout("triang.out");

const double eps = 1e-3;
const int NMAX = 1505;

int n, ans;
struct point
{
    double x, y;
    bool operator <(const point& a) const
    {
        if (abs(x-a.x) > eps)
            return x < a.x;
        if (abs(y-a.y) > eps)
            return y < a.y;
        return 0;
    }
};
point points[NMAX];
set<point> s;

point rota(const point& a, const point& b)
{
    double cos = 1.0/2, sin = sqrt(3)/2;
    point c;
    c.x = a.x+(b.x-a.x)*cos-(b.y-a.y)*sin;
    c.y = a.y+(b.x-a.x)*sin+(b.y-a.y)*cos;
    return c;
}

int main()
{
    fin >> n;
    for (int i = 1; i <= n; i++)
    {
        fin >> points[i].x >> points[i].y;
        for (int j = 1; j < n; j++)
            if (s.find(rota(points[i], points[j])) != s.end())
                ans++;
        s.insert(points[i]);
    }
    fout << ans;
    return 0;
}