Link:
http://acm.hdu.edu.cn/showproblem.php?pid=4160
Code:
#include <stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespacestd;#defineN 550///MatchstructNode {intW, L, H;} A[n];intG[n][n], used[n], p[n], N;intCMP (node n1, node N2) {if(n1.w!=N2.W)returnN1.W >N2.W; if(n1.l!=n2.l)returnN1.L >N2.L; returnN1.h >n2.h;}BOOLFind (intu) { for(intI=1; i<=n; i++) { if(!used[i] &&G[u][i]) {Used[i]=1; if(!p[i] | |Find (P[i])) {P[i]=u; return true; } } } return false;}intMain () { while(SCANF ("%d", &N), N) {intI, J; Memset (A,0,sizeof(a)); memset (G,0,sizeof(G)); for(i=1; i<=n; i++) scanf ("%d%d%d", &A[I].W, &A[I].L, &a[i].h); Sort (a+1, a+n+1, CMP); for(i=1; i<=n; i++) { for(j=1; j<i; J + +) { if(A[I].W<A[J].W && a[i].l<a[j].l && a[i].h<a[j].h) G[I][J]=1; } } intAns =0; Memset (P,0,sizeof(p)); for(i=1; i<=n; i++) {memset (used,0,sizeof(used)); if(Find (i)) ans++; } printf ("%d\n", N-ans); } return 0;}
(match) Dolls--hdu--4160