Cod sursa(job #2044470)

Utilizator stefanxdanDanila Sergiu Stefan stefanxdan Data 21 octombrie 2017 10:26:22
Problema Infasuratoare convexa Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
#include <bits/stdc++.h>
#define nmax 505
using namespace std;
ifstream fin("parelel.in");
ofstream fout("parelel.out");

struct Punct
{
    int x, y;
};

Punct P,a[nmax];
Punct mij[nmax*nmax];
int p,n,i, j;


inline bool Compara(Punct A, Punct B)
{
    if(A.y == B.y) return A.x < B.x;
    return A.y < B.y;
}

int main()
{
    fin >> n;
    for(i = 1; i <= n; i++)
        fin >> a[i].x >> a[i].y;
    for(i = 1; i < n; i++ )
        for(j = 2; j <= n; j++)
        {
            p++;
            mij[p].x= (a[i].x +a[j].x)/2;
            mij[p].y= (a[i].y +a[j].y)/2;
        }
    sort(mij+1, mij+1+n, Compara);
    i=1;
    while(i <= p)
    {
        P=mij[i];
        k=1;
        while(P=mij[i])
            k++, i++;
        sol+=k*(k-1)/2;

    }

}