1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
| #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<queue> #include<map> #include<stack> #include<cmath> #include<set> #include<bitset> #include<complex> #include<assert.h> #define inc(i,l,r) for(int i=l;i<=r;i++) #define dec(i,l,r) for(int i=l;i>=r;i--) #define link(x) for(edge *j=h[x];j;j=j->next) #define mem(a) memset(a,0,sizeof(a)) #define ll long long #define eps 1e-10 #define succ(x) (1<<(x)) #define lowbit(x) (x&(-x)) #define sqr(x) ((x)*(x)) #define mid (x+y)/2 #define NM 15 #define nm 5005 using namespace std; const double pi=acos(-1); const int inf=1e9+7; ll read(){ ll x=0,f=1;char ch=getchar(); while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();} while(isdigit(ch))x=x*10+ch-'0',ch=getchar(); return f*x; }
int n,m,tot,a[NM],p[nm],ans,b[NM]; double d[nm],g[nm]; vector<int>c[NM];
bool _check(double t){ double s=0; inc(i,1,tot-1)s+=asin(b[i]/t/2); return s>asin(b[tot]/t/2); } bool check(double t){ double s=0; inc(i,1,tot)s+=asin(b[i]/t/2); return s<pi; }
int main(){ int _=read();while(_--){ n=read();inc(i,1,n)a[i]=read(); sort(a+1,a+1+n); m=succ(n)-1; inc(i,7,m){ tot=0;d[i]=g[i]=0; inc(j,1,n)if(i&succ(j-1))b[++tot]=a[j]; if(tot<3)continue; double R=0;int cnt=0; inc(j,1,tot-1)cnt+=b[j]; if(cnt<b[tot])continue; cnt=0; if(!check(b[tot]/2.0)){ for(double x=b[tot]/2.0,y=10000;cnt<=100;cnt++) if(check(mid))R=y=mid;else x=mid; inc(j,1,tot)g[i]+=sqrt(sqr(R)-sqr(b[j])/4.0)*b[j]/2; }else{ for(double x=b[tot]/2.0,y=10000;cnt<=100;cnt++) if(_check(mid))R=y=mid;else x=mid; inc(j,1,tot-1)g[i]+=sqrt(sqr(R)-sqr(b[j])/4.0)*b[j]/2; g[i]-=sqrt(sqr(R)-sqr(b[tot])/4.0)*b[tot]/2; } } d[0]=1; inc(i,0,m)if(d[i]>eps){ for(int t=m^i,j=t;j;j=(j-1)&t)if(g[j]>eps){ double cnt=d[i]*g[j]; if(d[i|j]<cnt)d[i|j]=cnt,p[i|j]=i; } } ans=1;tot=0;d[0]=0; inc(i,1,m)if(d[i]>d[ans])ans=i; printf("%.10lf\n",d[ans]); for(;ans;ans=p[ans]){ int t=ans^p[ans]; if(g[t]<eps)continue; c[++tot].clear(); inc(i,1,n)if(t&succ(i-1))c[tot].push_back(i); } printf("%d\n",tot); inc(i,1,tot){printf("%d",(int)c[i].size());for(int&j:c[i])printf(" %d",a[j]);putchar('\n');} } return 0; }
|