题目

代码
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<int, int>;
#define x first
#define y second
const int N = 2010;
pll a[N];
int main()
{
int n;
scanf("%d", &n);
map<pll, int> cnt;
for (int i = 1; i <= n; i++)
{
scanf("%d%d", &a[i].x, &a[i].y);
cnt[{a[i].x, a[i].y}]++;
}
ll ans = 0;
for (int i = 1; i <= n; i++)
{
map<ll, vector<int>> lenmp;
for (int j = 1; j <= n; j++)
{
ll len = 1ll * (a[i].x - a[j].x) * (a[i].x - a[j].x) + 1ll * (a[i].y - a[j].y) * (a[i].y - a[j].y);
if (len)
lenmp[len].push_back(j);
}
for (auto &u : lenmp)
{
vector<int> &id = u.y;
int sz = id.size();
if (sz < 2)
continue;
ans += sz * (sz - 1) / 2;
int del = 0;
for (int j = 0; j < id.size(); j++)
{
int u = id[j];
int cx = a[i].x, cy = a[i].y;
int x = a[u].x, y = a[u].y;
int px = 2 * cx - x, py = 2 * cy - y;
del += cnt[{px, py}];
}
ans -= del / 2;
}
}
printf("%lld", ans);
}