Cod sursa(job #3285994)

Utilizator hiken056Stefan Rusu hiken056 Data 13 martie 2025 17:27:21
Problema Trapez Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.13 kb
#include <bits/stdc++.h>

using namespace std;

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

const int MAXN = 1e3 + 5;
int N, ans;

struct point {
   int x;
   double y;
//    bool operator < (point& a) const {
//         if ( x )
//    }
} puncte[MAXN];


struct line
{
    point a, b;
    double slope;
}lines[MAXN];

int main () {
    fin >> N;
    int k = 1;
    ans = 0;
    for ( int i = 1; i <= N; ++ i ) {
        fin >> puncte[i].x >> puncte[i].y;
    }
    for ( int i = 1; i < N; ++ i ) {
        for ( int j = i + 1; j <= N; ++ j ) {
            point a = puncte[i];
            point b = puncte[j];
            lines[k].a = a;
            lines[k].b = b;
            lines[k].slope = (b.y - a.y)/(b.x - a.x);
            k ++;
        }
    }
    k --;
    // for ( int i = 1; i <= k; ++ i ) {
        
    //     fout << lines[i].a.x << ", " <<lines[i].a.y << "   " << lines[i].b.x << ", " << lines[i].b.y << "   " << lines[i].slope << '\n';
    // }
    for ( int i = 1; i < k; ++ i ) {
        for ( int j = i + 1; j <= k; ++ j ) {
            if ( lines[i].slope == lines[j].slope ) ans ++;
        }
    }
    fout << ans;
}