Pagini recente » Cod sursa (job #350819) | Cod sursa (job #2477969) | Cod sursa (job #576143) | Cod sursa (job #1499307) | Cod sursa (job #2939296)
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
using i64 = long long;
constexpr size_t LIM = 1005;
set<pair<i64, i64>> points;
pair<i64, i64> points_array[LIM];
int N, i, j, ans;
double x, y;
static inline i64 read_i64(ifstream& fin) {
i64 ans = 0, sign = 1;
char ch;
while (fin >> ch && ch != '.') {
if (ch == '-') sign = -1;
else ans = ans * 10 + ch - '0';
}
for (int k = 0; k < 4; k++) {
fin >> ch;
ans = ans * 10 + ch - '0';
}
return ans * sign;
}
static inline void read() {
ifstream fin("patrate3.in");
fin >> N;
for (i = 0; i < N; i++) {
x = read_i64(fin);
y = read_i64(fin);
points_array[i] = make_pair(x, y);
points.insert(points_array[i]);
}
fin.close();
}
static inline void write() {
ofstream fout("patrate3.out");
fout << ans;
fout.close();
}
static inline void solve() {
for (i = 0; i < N; i++) {
for (j =0; j < N; j++) {
if (points_array[i] < points_array[j]) {
const auto& p1 = points_array[i];
const auto& p2 = points_array[j];
pair<i64, i64> diff = { abs(p1.first - p2.first), abs(p1.second - p2.second) };
const i64 x = diff.first, y = diff.second;
diff.first = -y, diff.second = x;
pair<i64, i64> p3 = { p1.first + diff.first, p1.second + diff.second };
pair<i64, i64> p4 = { p2.first + diff.first, p2.second + diff.second };
if (points.find(p3) != points.end() && points.find(p4) != points.end()) ans++;
}
}
}
}
int main() {
read();
solve();
write();
return 0;
}