Pagini recente » Cod sursa (job #1896758) | Cod sursa (job #305269) | Cod sursa (job #2599613) | Cod sursa (job #3287696) | Cod sursa (job #1480660)
#include <iostream>
#include <fstream>
#include <unordered_set>
using namespace std;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
#define H(x, y) (1LL * x * 1e9 + y)
const int NMax = 1005;
pair < int, int > Points[NMax];
unordered_set < long long int > Hash;
bool solve(int a, int b){
int x = Points[a].first, y = Points[a].second,
X = Points[b].first, Y = Points[b].second;
int dx = X - x;
int dy = y - Y;
int z = x + dy, t = y + dx,
Z = X + dy, T = Y + dx;
return(Hash.find(H(z, t)) != Hash.end() && Hash.find(H(Z, T)) != Hash.end());
}
int main(){
int n, ans;
long double a, b;
fin >> n;
for(int i = 1; i <= n; i++){
fin >> a >> b;
a *= 1e4; b *= 1e4;
Points[i] = make_pair(a, b);
Hash.insert(H(a, b));
}
ans = 0;
for(int i = 1; i <= n; i++){
for(int j = i + 1; j <= n; j++){
ans += solve(i, j);
ans += solve(j, i);
}
}
fout << ans;
return 0;
}