Pagini recente » Cod sursa (job #767999) | Cod sursa (job #527177) | Cod sursa (job #1602996) | Cod sursa (job #1062357) | Cod sursa (job #2624923)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
vector<pair<int,int>> pct;
set<pair<int,int>> mult;
int main()
{
int n;
double x,y;
fin>>n;
for (int i=0; i<n; i++) {
fin>>x>>y;
pct.push_back(make_pair((int)round(x*10000), (int)round(y*10000)));
mult.insert(pct[i]);
}
sort(pct.begin(), pct.end());
int nr=0;
for (int i=0; i<n-1; i++) {
for (int j=i+1; j<n; j++) {
if (pct[i].second < pct[j].second) {
int distx = pct[j].first - pct[i].first;
int disty = pct[j].second - pct[i].second;
pair<int,int> pct3, pct4;
pct3 = make_pair(pct[i].first - disty, pct[i].second + distx);
pct4 = make_pair(pct[j].first - disty, pct[j].second + distx);
if (mult.find(pct3) != mult.end() &&
mult.find(pct4) != mult.end())
nr++;
}
}
}
fout<<nr;
fin.close();
fout.close();
return 0;
}