Pagini recente » Cod sursa (job #845364) | Cod sursa (job #2804254) | Cod sursa (job #2853171) | Cod sursa (job #1665276) | Cod sursa (job #1321964)
#include<fstream>
#include<algorithm>
#include<unordered_map>
using namespace std;
int n,nr;
long double aux;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
struct duo
{
long long x, y;
}v[100001];
bool cmp(duo x, duo y)
{
return (x.x < y.x || (x.x == y.x &&x.y < y.y ));
}
void citire()
{
fin>>n;
for(int i=0;i<n;++i)
{
fin>>aux;
v[i].x=round(aux*10000);
fin>>aux;
v[i].y=round(aux*10000);
}
}
void solve()
{
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;
}
int main()
{
citire();
solve();
}