题面
题解
不难发现最小圆覆盖的随机增量法复杂度还是正确的
所以现在唯一的问题就是给定若干个点如何求一个\(m\)维的圆
其实就是
//minamoto#include#define R register#define inline __inline__ __attribute__((always_inline))#define fp(i,a,b) for(R int i=(a),I=(b)+1;i I;--i)#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)using namespace std;char buf[1<<21],*p1=buf,*p2=buf;inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}int read(){ R int res,f=1;R char ch; while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1); for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0'); return res*f;}double readdb(){ R double x=0,y=0.1,f=1;R char ch; while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1); for(x=ch-'0';(ch=getc())>='0'&&ch<='9';x=x*10+ch-'0'); for(ch=='.'&&(ch=getc());ch>='0'&&ch<='9';x+=(ch-'0')*y,y*=0.1,ch=getc()); return x*f;}const int N=2e4+5;const double eps=1e-8;inline int sgn(double x){return x<-eps?-1:x>eps;}int n,k;struct node{ double a[9]; inline double &operator [](const int &x){return a[x];} inline node operator +(node &b)const{ node c; fp(i,1,k)c[i]=a[i]+b[i]; return c; } inline node operator -(node &b)const{ node c; fp(i,1,k)c[i]=a[i]-b[i]; return c; } inline double operator ^(node &b)const{ double res=0; fp(i,1,k)res+=a[i]*b[i]; return res; } inline node operator *(const double &b)const{ node c; fp(i,1,k)c[i]=a[i]*b; return c; } inline double norm()const{ double res=0; fp(i,1,k)res+=a[i]*a[i]; return res; }}p[N],c[N],o;double a[9][9],r;void Gauss(int n){ fp(i,1,n){ int k=i; fp(j,i+1,n)if(fabs(a[j][i])>fabs(a[k][i]))k=j; if(i!=k)fp(j,i,n+1)swap(a[i][j],a[k][j]); double t=1.0/a[i][i]; fp(j,i,n+1)a[i][j]*=t; fp(j,i+1,n)fd(k,n+1,i)a[j][k]-=a[j][i]*a[i][k]; } fd(i,n,1){ if(!sgn(a[i][i])){a[i][i]=0;continue;} double t=1.0/a[i][i]; fd(j,i-1,1)fd(k,n+1,i)a[j][k]-=a[i][k]*t*a[j][i]; a[i][n+1]*=t; }}void circle(int n){ if(n==0)return o=c[1],r=0,void(); if(n==1)return o=c[1],r=0,void(); if(n==2)return o=(c[1]+c[2])*0.5,r=(o-c[1]).norm(),void(); fp(i,2,n)c[i]=c[i]-c[1]; fp(i,2,n)fp(j,i,n)a[i-1][j-1]=a[j-1][i-1]=(c[i]^c[j])*2; fp(i,2,n)a[i-1][n]=c[i]^c[i]; Gauss(n-1); o=c[1]; fp(i,2,n)o=c[i]*a[i-1][n]+o; r=(o-c[1]).norm(); fp(i,2,n)c[i]=c[i]+c[1];}void solve(int n,int cnt){ circle(cnt); fp(i,1,n)if(sgn((p[i]-o).norm()-r)>0) c[cnt+1]=p[i],solve(i-1,cnt+1);}int main(){// freopen("testdata.in","r",stdin); srand(20030719); n=read(),k=read(); fp(i,1,n)fp(j,1,k)p[i][j]=readdb(); random_shuffle(p+1,p+1+n); solve(n,0); fp(i,1,k)printf("%.6lf%c",o[i]," \n"[i==k]); return 0;}