Cod sursa(job #2422268)

Utilizator oogaboogauvuvwevwevwe onyetenyevwe ugwemubwem ossas oogabooga Data 18 mai 2019 11:49:57
Problema Trapez Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.84 kb
#include <bits/stdc++.h>

using namespace std;

ifstream in("trapez.in");
ofstream out("trapez.out");

#define PI 3.14159265

struct pct{
    long long x,y;
    bool operator <(const pct &p) const{
        return this->x < p.x || this->y < p.y;
    }
    bool operator !=(const pct &p) const{
        return this->x != p.x || this->y != p.y;
    }
};

struct drt{
    long long f,s,al;
};

int nrPct,ans;
pct p[1005];
vector <drt> dr;
bitset <1005> mk[1005];

int main(){
    ios::sync_with_stdio(0);

    in>>nrPct;

    for(int i = 1; i <= nrPct; ++i){
        in>>p[i].x>>p[i].y;
    }

    for(int i = 1; i < nrPct; ++i)
        for(int j = i + 1; j <= nrPct; ++j){
            long long a = abs(p[i].x - p[j].x);
            long long b = abs(p[i].y - p[j].y);
            long double c = sqrt(1LL * (1LL * p[i].x - 1LL * p[j].x) * (1LL * p[i].x - 1LL * p[j].x) + 1LL * (1LL * p[i].y - 1LL * p[j].y) * (1LL * p[i].y - 1LL * p[j].y));

            long long al = asin(b / c) * 180.0 / PI;

            pct mx = max(p[i], p[j]);
            pct mn = p[i] != mx ? p[i] : p[j];

            if(mx.x >= mn.x && mx.y >= mn.y){
                //cout<<i<<", "<<j<<": "<<b<<" "<<c<<" "<<al<<"\n";
                dr.push_back({i, j, al});
            }
            else{
                //cout<<i<<", "<<j<<": "<<b<<" "<<c<<" "<<180 - al<<"\n";
                dr.push_back({i, j, 180 - al});
            }
        }

    /*for(int i = 0; i < dr.size(); ++i){
        cout<<"("<<p[dr[i].f].x<<", "<<p[dr[i].f].y<<"), ("<<p[dr[i].s].x<<", "<<p[dr[i].s].y<<"): "<<dr[i].al<<"\n";
    }*/

    for(int i = 0; i < dr.size() - 1; ++i)
        for(int j = i + 1; j < dr.size(); ++j){
            if(dr[i].al == dr[j].al && mk[i][j] == 0) ++ans, mk[i][j] = mk[j][i] = 1;


        }

    out<<ans;



    return 0;
}