Test instructions: There are some boxes, large boxes can be small boxes, but must h>h,w>w,l>l, to find out the outermost can be left a few boxes cannot be nested.
Analysis: Thinking of each box will only be another box, so make up one or two points matching model, only need to find the biggest match, because there is no match can not be nested, has been matched to find nested its box, the result is the total number of boxes-the maximum match. The
code is as follows:=========================================================================================================== ============================
#include <stdio.h>#include<string.h>Const intMAXN =507;Const intOO = 1e9+7;structpoint{intWI, Li, hi;} P[MAXN];intG[MAXN][MAXN], LY[MAXN], N;BOOLUSED[MAXN];BOOLOK (Point A, point B) {if(A.hi<b.hi && a.li<b.li && a.wi<b.wi)return true; return false;}BOOLFind (inti) { for(intj=1; j<=n; J + +) { if(!used[j] &&G[i][j]) {Used[j]=true; if(! LY[J] | |Find (Ly[j])) {Ly[j]=i; return true; } } } return false;}intXYL () {memset (Ly,0,sizeof(Ly)); intAns =0; for(intI=1; i<=n; i++) {memset (used,false,sizeof(used)); if(Find (i) = =true) ans++; } returnans;}intMain () { while(SCANF ("%d", &N), N) {intI, J; memset (G,0,sizeof(G)); for(i=1; i<=n; i++) scanf ("%d%d%d", &p[i].wi, &p[i].li, &P[i].hi); for(i=1; i<=n; i++) for(j=1; j<=n; J + +) { if(OK (P[i], p[j]) = =true) G[i][j]=1; } printf ("%d\n", N-XYL ()); } return 0;}
Dolls-4160 (simple binary graph matching)