constintMAXN=31,MAXM=31;constdoubleINF=1e18,EPS=1e-8;namespaceSimplex{intn,m;doublea[MAXM][MAXN];intidx[MAXN];// index of non-basic variableintidy[MAXM];// index of basic variablevoidpivot(intx,inty){doublet=-1/a[y][x];a[y][x]=-1;for(inti=0;i<=n+1;++i){a[y][i]*=t;}for(inti=1;i<=m+3;++i){// m must + 3if(i!=y&&fabs(a[i][x])>EPS){doublet0=a[i][x];a[i][x]=0;for(intj=0;j<=n+1;++j){a[i][j]+=a[y][j]*t0;}}}std::swap(idx[x],idy[y]);}doublesimplex(){for(;;){intx=-1;for(inti=0;i<=n;++i){if(a[m+1][i]>EPS){x=i;break;}}if(x==-1)break;inty=-1;doublemindelta=INF;for(inti=1;i<=m;++i){if(a[i][x]<-EPS&&chkmin(mindelta,-a[i][n+1]/a[i][x]))y=i;}if(y==-1)// unboundedreturn+INF;pivot(x,y);}returna[m+1][n+1];}boolinit(intn_,intm_){n=n_;m=m_;for(inti=0;i<=n;++i){idx[i]=i;}for(inti=1;i<=m+2;++i){idy[i]=i+n;}// setting the objective funtion to -x_0a[m+1][0]=-1;// adding +x_0 to each constraintsfor(inti=1;i<=m;++i){a[i][0]=+1;}// let k be the index of minimum b_iintk=1;for(inti=2;i<=m;++i){if(a[i][n+1]<a[k][n+1])k=i;}pivot(0,k);if(simplex()<-EPS)// infeasiblereturnfalse;// adding a constraint x_0 = 0for(inti=0;i<=n+1;++i){a[m+2][i]=-a[m+1][i];}// setting the objective funtion to the originalm+=2;returntrue;}voidprintAnswer(intn_){staticdoubleans[MAXN*2+5];for(inti=1;i<=m;++i){ans[idy[i]]=a[i][n+1];}for(inti=1;i<=n_;++i){printf("%.10f ",ans[i]);}putchar('\n');}}intN,M,T;voidinput(){read(N);read(M);read(T);for(inti=1;i<=N;++i){// we don't need the objective when initializingscanf("%lf",&Simplex::a[M+3][i]);}for(inti=1;i<=M;++i){for(intj=1;j<=N;++j){scanf("%lf",&Simplex::a[i][j]);// convert standard form to augmented form// attention that the sign of coefficient is different compared with CLRSSimplex::a[i][j]=-Simplex::a[i][j];}scanf("%lf",&Simplex::a[i][N+1]);}}voidsolve(){if(Simplex::init(N,M)==false){puts("Infeasible");return;}doubleans=Simplex::simplex();if(ans==INF)puts("Unbounded");else{printf("%.10f\n",ans);if(T)Simplex::printAnswer(N);}}