Cod sursa(job #2636750)

Utilizator OvidRata Ovidiu Ovid Data 19 iulie 2020 16:20:37
Problema Trapez Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.9 kb
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


ifstream f1("trapez.in"); ofstream f2("trapez.out");
#define cin f1
#define cout f2


int t, n, x[1010], y[1010];
map<pii, int> h;
set<pii> s;


int32_t main(){
INIT
cin>>n;
for(int i=1; i<=n; i++){
    cin>>y[i]>>x[i];
}

int cnt=0;

for(int i=1; i<=n; i++){
    for(int j=i+1; j<=n; j++){
        int dx=x[j]-x[i], dy=y[j]-y[i]; int gcd=__gcd(dx, dy); dx/=gcd; dy/=gcd;
        if(dx<0){dx=-dx; dy=-dy;}
        pii f=mp(dx, dy);
        cnt+=h[f]; h[f]++;
    }
}

cout<<cnt;



return 0;
}