Pagini recente » Cod sursa (job #1303207) | Cod sursa (job #2090164) | Cod sursa (job #2999353) | Monitorul de evaluare | Cod sursa (job #1003744)
#include <fstream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
#define eps 0.0001
/**************** GLOBALS ****************/
struct punct {
float x, y;
friend bool operator < (const punct &a, const punct &b) {
if (a.x + eps < b.x || (a.x - b.x > -eps && a.x - b.x < eps && a.y + eps < b.y))
return 1;
return 0;
}
}p, p1, p2;
vector<punct> v;
int i, j, n, result;
float dx, dy;
/***************** MAIN *****************/
int main() {
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
// Read
fin >> n;
for (i = 1; i <= n; i++) {
fin >> p.x >> p.y;
v.push_back(p);
}
// Compute
sort(v.begin(), v.end());
for (i = 0; i < n; i++)
for (j = i + 1; j < n; j++) {
p.x = (v.at(i).x + v.at(j).x) / 2;
p.y = (v.at(i).y + v.at(j).y) / 2;
dx = fabs(p.x - v.at(i).x);
dy = fabs(p.y - v.at(i).y);
if (v.at(i).y + eps < v.at(j).y) {
p1.x = p.x + dy;
p1.y = p.y - dx;
p2.x = p.x - dy;
p2.y = p.y + dx;
} else {
p1.x = p.x - dy;
p1.y = p.y - dx;
p2.x = p.x + dy;
p2.y = p.y + dx;
}
if (binary_search(v.begin(), v.end(), p1) && binary_search(v.begin(), v.end(), p2))
result++;
}
// Print
fout << result / 2;
cout << result / 2;
}