Pagini recente » Cod sursa (job #2836605) | Cod sursa (job #2777634) | Cod sursa (job #1727938) | Cod sursa (job #706422) | Cod sursa (job #1051825)
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <algorithm>
using namespace std;
unordered_map<double,int> unmap;
unordered_set<double> unset;
struct punct{
double x;
double y;
};
punct v[1001],p;
int contor=0;
int main()
{
int n,i;
ifstream f("patrate3.in");
ofstream g("patrate3.out");
f>>n;
double xx,yy;
for(i=1;i<=n;i++){
f>>xx>>yy;
p.x=xx;
p.y=yy;
v[i]=p;
unmap.insert(make_pair<double&,int&>(xx,i));
unmap.insert(make_pair<double&,int&>(yy,i));
}
//sort(v+1);
//sort(v+n+1);
//cout<<(unmap.find(2.5212)!=unmap.end());
int j;
punct a,b,c,d;
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
if(i!=j){
a=v[i];
b=v[j];
c.x=a.x+(a.y-b.y);
c.y=a.y+(b.x-a.x);
d.x=b.x+(a.y-b.y);
d.y=b.y+(b.x-a.x);
// cout<<i<<" cu "<<j<<" face C("<<c.x<<", "<<c.y<<") si D("<<d.x<<", "<<d.y<<")"<<'\n';
int ic,id;
unordered_map<double,int>::const_iterator got = unmap.find (c.x);
if ( got != unmap.end() )
ic=got->second;
//std::cout << got->first << " is " << got->second;
//cout<<endl;
got=unmap.find(c.y);
if ( got != unmap.end() )
if(ic==got->second){
// cout<<"c gasit"<<ic<<" cu "<<a.x<<","<<a.y<<" si"<<b.x<<","<<b.y<<" hai si d care e"<<d.x;
contor++;
}
//cout<<endl;
// cout<<(unmap.find(d.x)!=unmap.end())<<"M"<<d.x;
got=unmap.find(d.x);
if ( got != unmap.end() )
id=got->second;
// cout<<id;
//cout<<endl;
got=unmap.find(d.y);
if ( got != unmap.end() )
if(id==got->second){
// cout<<"d gasit"<<id<<" cu "<<a.x<<","<<a.y<<" si"<<b.x<<","<<b.y<<" hai si c care e"<<c.x;
contor++;
}
//cout<<(unmap.find(c.y)!=unmap.end());
}
}
// cout<<endl;
}
g<<contor;
return 0;
}