Pagini recente » Cod sursa (job #2419411) | Cod sursa (job #1205486) | Cod sursa (job #2644683) | Cod sursa (job #1843449) | Cod sursa (job #2613875)
#include <fstream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;
ifstream cin("patrate3.in");
ofstream cout("patrate3.out");
int n;
vector < pair <double,double> >pct;
void read()
{
cin>>n;
pct.resize(n);
for(int i=0;i<n;i++)
cin>>pct[i].first>>pct[i].second;
}
int bin(double x,double y)
{
int st=0,dr=n-1;
while(st<=dr)
{
int mij=(st+dr)/2;
if(pct[mij].first==x && pct[mij].second==y)
return mij;
if(pct[mij].first<x)
st=mij+1;
else if(pct[mij].first==x)
{
if(pct[mij].second<y)
st=mij+1;
else
dr=mij-1;
}
else
dr=mij-1;
}
return -1;
}
void solve()
{
int ans=0;
for(int i=0;i<n-1;i++)
for(int j=i+1;j<n;j++)
{
double x0=pct[i].first,y0=pct[i].second;
double x1=pct[j].first,y1=pct[j].second;
double x2,y2,x3,y3;
double mijX=(x0+x1)/2,mijY=(y0+y1)/2;
double dx=abs(x0-mijX),dy=abs(y0-mijY);
//cout<<mijX<<" "<<mijY<<" "<<dx<<" "<<dy<<"\n";
if(y0<y1)
{
x2=mijX+dy;
y2=mijY-dx;
x3=mijX-dy;
y3=mijY+dx;
}
else
{
x2=mijX-dy;
y2=mijY-dx;
x3=mijX+dy;
y3=mijY+dx;
}
int p1=bin(x2,y2);
int p2=bin(x3,y3);
if(p1!=-1 && p2!=-1)
ans++;
}
cout<<ans;
}
int main()
{
read();
sort(pct.begin(),pct.end());
solve();
return 0;
}