点击打开链接
需要排下序。。
#include"stdio.h"
#include"string.h"
#include"stdlib.h"
#define N 501
struct node
{int a,b,c;
}aa[N];
int map[N][N],v[N],link[N];
int n;
int cmp(const void*a,const void*b)
{struct node *c,*d;c=(struct node*)a;d=(struct node*)b;if(c->a!=d->a)return c->a-d->a;else if(c->b!=d->b)return c->b-d->b;else return c->c-d->c;
}
int dfs(int k)
{int i;for(i=1;i<=n;i++){if(map[k][i]&&!v[i]){v[i]=1;if(link[i]==-1||dfs(link[i])){link[i]=k;return 1;}}}return 0;
}
int main()
{int i,j,ans,a,b,c;while(scanf("%d",&n)!=-1){if(!n)break;aa[0].a=aa[0].b=aa[0].c=0;for(i=1;i<=n;i++){scanf("%d%d%d",&a,&b,&c);aa[i].a=a;aa[i].b=b;aa[i].c=c;}qsort(aa,n+1,sizeof(aa[0]),cmp);memset(map,0,sizeof(map));for(i=1;i<n;i++){for(j=i+1;j<=n;j++){if(aa[i].a<aa[j].a&&aa[i].b<aa[j].b&&aa[i].c<aa[j].c)map[i][j]=1;}}ans=0;memset(link,-1,sizeof(link));for(i=1;i<=n;i++){memset(v,0,sizeof(v));if(dfs(i))ans++;}printf("%d\n",n-ans);}return 0;
}