Cod sursa(job #2601827)

Utilizator dorufDoru Floare doruf Data 15 aprilie 2020 11:53:07
Problema Trapez Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <bits/stdc++.h>
using namespace std;
using llong = int64_t;

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

const int val0 = 2 * 1e9 + 5;

unordered_map<double,int> pt;
vector<pair<int,int>> v;
int n;

llong nrT;

int main()
{
	ios_base::sync_with_stdio(false);
	fin.tie(0);
	fout.tie(0);

	fin >> n, v = vector<pair<int,int>> (n);
	for (auto& it : v) fin >> it.first >> it.second;

	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j)
		{
			double x = v[i].first - v[j].first, y = v[i].second - v[j].second;
            nrT += pt[(y ? (x / y) : val0)]++;
		}

	fout << nrT;
}