Pagini recente » Cod sursa (job #1961777) | Cod sursa (job #2035360) | Cod sursa (job #2483528) | Cod sursa (job #527049) | Cod sursa (job #1315424)
#include <fstream>
#include <algorithm>
#include <unordered_map>
using namespace std;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
struct duo
{
long long x, y;
};
bool cmp(duo x, duo y)
{
return (x.x < y.x || (x.x == y.x &&x.y < y.y ));
}
duo v[100001];
int main()
{
int n;
fin >> n;
int nr = 0;
for (int i = 0; i <= n-1; i++)
{
long double aux;
fin >> aux;
v[i].x=round(aux*10000);
fin >> aux;
v[i].y = round(aux * 10000);
}
sort(v, v + n, cmp);
for (int i = 0; i < n - 2; i++)
{
for (int j = i + 1; j < n; j++)
{
long long dx = abs(v[i].x - v[j].x);
long long dy = abs(v[i].y - v[j].y);
duo aux1,aux2;
aux1.x = v[i].x + dy;
aux1.y = v[i].y + dx;
aux2.x = v[j].x + dy;
aux2.y = v[j].y + dx;
if (binary_search(v, v + n, aux1, cmp) && binary_search(v, v + n, aux2, cmp))
nr++;
}
}
fout << nr;
}