Pagini recente » Cod sursa (job #1520146) | Cod sursa (job #1702987) | Cod sursa (job #2361289) | Cod sursa (job #1630740) | Cod sursa (job #1282178)
//Deresu Roberto - FMI
//Re :)
#include<fstream>
#include<algorithm>
#include<unordered_map>
#define nx 100000
using namespace std;
int n,rez;
struct punct
{
int x,y;
}a[1007];
unordered_map<int,int>mymap;
unordered_map<int,int> :: iterator it;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
int cmp(punct a, punct b)
{
if(a.x < b.x || (a.x == b.x && a.y < b.y)) return 1;
return 0;
}
int cauta(int x, int y)
{
it = mymap.find(x);
while(it != mymap.end() && it->first == x)
{
if(it->second == y) return 1;
it++;
}
it = mymap.find(x);
while(it != mymap.begin() && it->first == x)
{
it--;
if(it->first == x && it->second == y) return 1;
}
return 0;
}
int numar()
{
double y;
fin>>y;
y *= nx;
int x = y;
if(x >= 0)
{
if(x%10 == 9) x = x/10+1;
else x = x/10;
}
else
{
if(-x%10 == 9) x = x/10-1;
else x = x/10;
}
return 2*x;
}
int main()
{
fin>>n;
for(int i=1;i<=n;i++)
{
a[i].x = numar();
a[i].y = numar();
mymap.insert(pair<int,int>(a[i].x,a[i].y));
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
{
int x3,y3,x4,y4;
x3 = a[i].x+a[i].y-a[j].y;
y3 = a[i].y+a[j].x-a[i].x;
x4 = a[i].y+a[j].x-a[j].y;
y4 = a[j].x+a[j].y-a[i].x;
if(cauta(x3,y3) && cauta(x4,y4)) rez++;
}
fout<<rez/2<<'\n';
return 0;
}