Pagini recente » Cod sursa (job #991912) | Cod sursa (job #991785) | Cod sursa (job #604032) | Cod sursa (job #1832553) | Cod sursa (job #1804736)
#include <iostream>
#include <fstream>
#include <set>
#include <cstring>
using namespace std;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
#define H(x, y) (x * 1e9 + y)
const int NMax = 1005;
pair < int, int > Points[NMax];
set < long long > Hash;
bool solve(int a, int b){
long long x = Points[a].first, y = Points[a].second,
X = Points[b].first, Y = Points[b].second;
long long dx = X - x, dy = y - Y;
long 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());
}
char buff[15];
void Read(long long &x){
int pos = 0;
bool s = 0;
x = 0;
fin >> buff;
if(buff[pos] == '-'){
s = 1;
pos++;
}
while(pos < strlen(buff))
{
if(buff[pos] >= '0' && buff[pos] <= '9'){
x = x * 10 + buff[pos] - '0';
}
pos++;
}
if(s) x = -x;
}
int main(){
long long n, ans, a, b;
fin >> n;
for(int i = 1; i <= n; i++){
Read(a); Read(b);
// fout << a <<" " <<b << "\n";
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 / 4;
return 0;
}