Cod sursa(job #2481829)

Utilizator Andy_ANDYSlatinaru Andrei Alexandru Andy_ANDY Data 27 octombrie 2019 14:47:09
Problema Trapez Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.89 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f ( "trapez.in" ); ofstream g ( "trapez.out" );
pair < long double ,long double > v[1005];
vector  <long double> unghi;
map < long double, int > unghi1;
map < long double, int > :: iterator it ;
int main()
{   int n;
    f>>n;
    for(int i=1;i<=n;i++) f>>v[i].first>>v[i].second;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
        {   /*if(v[i].first == v[j].first) unghi.push_back((2e9 + 2));
            else unghi.push_back((v[i].second-v[j].second)/(long double)(v[i].first-v[j].first));*/
            if( v[i].first==v[j].first ) unghi1[2e9 + 2]++;
            else unghi1 [ (v[i].second-v[j].second)/(long double)(v[i].first-v[j].first) ] ++;
        }
    int ans=0;
    for( it=unghi1.begin() ; it!=unghi1.end();it++)
    {   int val=it->second;
        ans+=(val*(val-1))/2;
    }
    g<<ans;
    return 0;
}