Cod sursa(job #3309322)

Utilizator raulthestormIlie Raul Ionut raulthestorm Data 3 septembrie 2025 15:54:54
Problema Triang Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.01 kb
#include <fstream>
#include <set>
#include <cmath>

using namespace std;
const double EPS = 1e-3;
const int NMAX = 1501;

int n, cnt;
struct punct
{
    double x, y;
    bool operator<(const punct &B)const
    {
        if(abs(x - B.x) > EPS)
            return x < B.x;
        //
        if(abs(y - B.y) > EPS)
            return y < B.y;
        return 0;
    }
} pc[NMAX];

set<punct> S;

ifstream f("triang.in");
ofstream g("triang.out");

punct rotatie(const punct &a, const punct &b)
{
    punct c;
    double sin = sqrt(3) / 2, cos = 1.0 / 2;
    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()
{
    f >> n;
    for(int i = 1; i <= n; i++)
    {
        f >> pc[i].x >> pc[i].y;
        for(int j = 1; j < n; j++)
            if(S.find(rotatie(pc[i], pc[j])) != S.end())
                cnt++;
        S.insert(pc[i]);
    }
    g << cnt;
    f.close();
    g.close();
    return 0;
}