太恶心了
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
//#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<iostream> #include<sstream> #include<cmath> #include<climits> #include<string> #include<map> #include<queue> #include<vector> #include<stack> #include<set> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; #define pb(a) push(a) #define INF 0x1f1f1f1f #define lson idx<<1,l,mid #define rson idx<<1|1,mid+1,r #define PI 3.1415926535898 template<class T> T min(const T& a,const T& b,const T& c) { return min(min(a,b),min(a,c)); } template<class T> T max(const T& a,const T& b,const T& c) { return max(max(a,b),max(a,c)); } void debug() { #ifdef ONLINE_JUDGE #else freopen("d:\in1.txt","r",stdin); freopen("d:\out1.txt","w",stdout); #endif } int getch() { int ch; while((ch=getchar())!=EOF) { if(ch!=' '&&ch!=' ')return ch; } return EOF; } struct situation { int h[4],w[4]; }sit[500]; struct answer { int h,w; answer(int h=0,int w=0):h(h),w(w){} bool operator < (const answer &ant) const { if(h*w!=ant.h*ant.w) return h*w<ant.h*ant.w; else return h<ant.h; } bool operator == (const answer &ant ) const { return h==ant.h&&w==ant.w; } }ans[2500]; int h[4],w[4]; void get() { int k=0; for(int st=0;st<(1<<4);st++) { int ord[4]={0,1,2,3}; do { k++; for(int i=0;i<4;i++) { if((1<<ord[i])&st) { sit[k].h[i]=w[ord[i]]; sit[k].w[i]=h[ord[i]]; }else { sit[k].h[i]=h[ord[i]]; sit[k].w[i]=w[ord[i]]; } } }while(next_permutation(ord,ord+4)); } } int deal() { int h,w; int k=0; for(int i=1;i<=24*16;i++) { //1 w=0,h=0; for(int j=0;j<4;j++) { h=max(h,sit[i].h[j]); w+=sit[i].w[j]; } if(h>w)swap(h,w); ans[++k]=answer(h,w); //2 w=0,h=0; for(int j=0;j<3;j++) { h=max(h,sit[i].h[j]); w+=sit[i].w[j]; } h+=sit[i].h[3]; w=max(w,sit[i].w[3]); if(h>w)swap(h,w); ans[++k]=answer(h,w); //3 h=max(sit[i].h[0],sit[i].h[1])+sit[i].h[2]+sit[i].h[3]; w=max(sit[i].w[0]+sit[i].w[1],sit[i].w[2],sit[i].w[3]); if(h>w)swap(h,w); ans[++k]=answer(h,w); //4 h=max(sit[i].h[0],sit[i].h[1])+max(sit[i].h[2],sit[i].h[3]); w=max(sit[i].w[0]+sit[i].w[1],sit[i].w[2]+sit[i].w[3]); if(sit[i].w[0]+sit[i].w[1]>=sit[i].w[2]+sit[i].w[3]) { if(sit[i].w[3]<=sit[i].w[0]&&sit[i].h[0]<=sit[i].h[1]) h=max(sit[i].h[0]+sit[i].h[3],sit[i].h[1]+sit[i].h[2]); } if(h>w)swap(h,w); ans[++k]=answer(h,w); //5 h=sit[i].h[0]; h+=max(sit[i].h[1],sit[i].h[2]+sit[i].h[3]); w=max(sit[i].w[0],sit[i].w[1]+max(sit[i].w[2],sit[i].w[3])); if(h>w)swap(h,w); ans[++k]=answer(h,w); } return k; } int main() { freopen("packrec.in","r",stdin); freopen("packrec.out","w",stdout); for(int i=0;i<4;i++) scanf("%d %d",&h[i],&w[i]); get(); int k=deal(); sort(ans+1,ans+k+1); k=unique(ans+1,ans+k+1)-ans; int res=ans[1].h*ans[1].w; printf("%d %d %d ",res,ans[1].h,ans[1].w); int i=2; while(ans[i].h*ans[i].w==res) { printf("%d %d ",ans[i].h,ans[i].w); i++; } return 0; }