玄学,O(n^3) 与 O(n) 之间的决斗

/*"Nothing is true."*/
#include<bits/stdc++.h>
using namespace std;
inline int min(int _a, int _b) {return _a < _b ? _a : _b;}
inline int max(int _a, int _b) {return _a > _b ? _a : _b;}
const int inf = 0x3f3f3f3f;
const double eps = 1e-12;

template <class _T> inline void rd(_T &_a) {
	int _f=0,_ch=getchar();_a=0;
	while(_ch < '0' || _ch > '9') {if(_ch=='-') _f=1; _ch=getchar();}
	while(_ch>='0'&&_ch<='9') _a = (_a << 1) + (_a << 3) +_ch-'0',_ch = getchar();
	if( _f ) _a = -_a;
}

struct node {
    double x, y;
} a[maxn], P;

int n;

int incircle(node x) {
    if(dis(P, x) <= R - eps) return true;
    return false;
}

node solve(node A, node B, node C) {
    node res;
    double a1 = B.x - A.x, b1 = B.y - A.y, c1 = (a1 * a1 + b1 * b1) / 2;
    double a2 = C.x - A.x, b2 = C.y - A.y, c2 = (a2 * a2 + b2 * b2) / 2;
    double d = a1 * b2 - a2 * b1;
    res.x = A.x + (c1 * b2 - c2 * b1) / d;
    res.y = A.y + (a1 * c2 - a2 * c1) / d;
    return res;
}

int main() {
    rd(n);
    for(int i = 1;i <= n; ++i) {
        scanf("%lf%lf\n", &a[i].x, &a[i].y);
    }
    random_shuffle(a + 1, a + n + 1);
    R = 0;
    for(int i = 1;i <= n; ++i) {
        if(incircle(a[i]) == 0) {
            P.x = a[i].x; P.y = a[i].y;
            for(int j = 1;j < i; ++j) {
                if(incircle(a[j] == 0) {
                    P.x = (a[i].x + a[j].x) / 2;
                    P.y = (a[i].y + a[j].y) / 2;
                    R = dis(P, a[i]);
                    for(int k = 1;k < j; ++k) {
                        if(incircle(a[k]) == 0) {
                            P = solve(a[i], a[j], a[k]);
                            R = dis(P, a[i]);
                        }
                    }
                }
            }
        }
    }
    printf("%.10lf\n%.10lf %.10lf\n", R, P.x, P.y);
    return 0;
}