B 暴力

思路

枚举两个点,得到圆心,使用unordered_map记录下该圆心被遍历过的次数即可,遍历时更新答案,时间复杂度 $O(n^2)$

代码

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vec2 = pair<double, double>;
const int N = 2e3 + 5;
ll px[N], py[N];

vec2 solver(ll a1, ll b1, ll c1, ll a2, ll b2, ll c2) {
    double up1 = (c1 * b2 - c2 * b1), up2 = (c1 * a2 - c2 * a1);
    double low1 = (a2 * b1 - a1 * b2), low2 = (b2 * a1 - b1 * a2);
    return vec2 {up1 / low1, up2 / low2};
}

struct pair_hash {
    template<class T1, class T2>
    std::size_t operator() (const std::pair<T1, T2>& p) const noexcept {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);
        return h1 ^ h2;
    }
};

unordered_map<vec2, int, pair_hash> mp;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> px[i] >> py[i];
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        mp.clear();
        for (int j = i + 1; j < n; ++j) {
            if (px[i] * py[j] == px[j] * py[i]) continue;
            auto p = solver(
                px[i], py[i], px[i] * px[i] + py[i] * py[i],
                px[j], py[j], px[j] * px[j] + py[j] * py[j]
            );
            mp[p]++;
            ans = max(ans, (int)mp[p]);
        }
    }

    cout << ans + 1 << endl;
    return 0;
}