Cod sursa(job #2789667)

Utilizator mateitudordmDumitru Matei mateitudordm Data 27 octombrie 2021 19:51:25
Problema Triang Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.25 kb
#include <bits/stdc++.h>
#define PI 3.14159265
#define sin1 sin(PI / 3)
#define cos1 cos(PI / 3)
#define sin2 sin(-PI / 3)
#define cos2 cos(-PI / 3)
#define eps 0.0001

using namespace std;

struct pct
{
    double x, y;
    bool operator<(const pct &a) const
    {
        if (abs(x - a.x) <= eps)
            return y + eps <= a.y;
        return x + eps <= a.x;
    }
};
set<pct> v;
set<pct>::iterator it1, aux;

int main()
{
    ifstream cin("triang.in");
    ofstream cout("triang.out");
    int i, cnt = 0, n;
    double x, y;
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> x >> y;
        pct m;
        m.x = x;
        m.y = y;
        for (it1 = v.begin(); it1 != v.end(); it1++)
        {
            double x1, x2, y1, y2, xx, yy;
            x1 = m.x, x2 = (*it1).x, y1 = m.y, y2 = (*it1).y;
            y2 -= y1, x2 -= x1;
            xx = x2 * cos1 - y2 * sin1;
            yy = x2 * sin1 + y2 * cos1;
            y1 += yy, x1 += xx;
            pct m;
            m.x = x1;
            m.y = y1;
            aux = v.find(m);
            if (aux != v.end())
                cnt++;
        }
        v.insert(m);
    }
    cout << cnt;
}