Pagini recente » Cod sursa (job #1600241) | Cod sursa (job #707301) | Cod sursa (job #322710) | Cod sursa (job #2341658) | Cod sursa (job #2622991)
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
vector<pair<int,int>> el;
set<pair<int, int>> h;
int main() {
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
int n, total = 0;
double a, b;
fin>>n;
for(int i=0;i<n;i++){
fin>>a>>b;
el.emplace_back((int)round(a*10000), (int)round(b*10000));
h.insert(el[i]);
}
fin.close();
sort(el.begin(), el.end());
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
if(el[j].first>el[i].first && el[j].second>el[i].second){
int dx = el[j].first-el[i].first;
int dy = el[j].second-el[i].second;
if(h.find(make_pair(el[i].first-dy, el[i].second+dx))!=h.end() && h.find(make_pair(el[j].first-dy, el[j].second+dx))!=h.end())
total++;
}
fout<<total;
fout.close();
return 0;
}