Dolls---hdu4160 (maximum match)

Source: Internet
Author: User

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=4160

There are n cuboid-shaped dolls, when the length and width of the height is less than the other time can be put in, each inside a maximum of one, ask the best set method, the last number of dolls can be left;

With the N-Max match on the line;

#include <cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespacestd;#defineN 550intN, Vis[n], used[n], maps[n][n];structnode{intx, Y, Z, DP;} A[n];intCMP (node p, node Q) {if(p.x!=q.x)returnP.x <q.x; Else if(p.y!=q.y)returnP.y <q.y; returnP.z <q.z;}BOOLFind (intu) {     for(intI=1; i<=n; i++)    {        if(!vis[i] &&Maps[u][i]) {Vis[i]=1; if(!used[i] | |Find (Used[i])) {Used[i]=u; return true; }        }    }    return false;}intMain () { while(SCANF ("%d", &N) {memset (A,0,sizeof(a)); memset (Used,0,sizeof(used)); memset (Maps,0,sizeof(maps));  for(intI=1; i<=n; i++) {scanf ("%d%d%d", &a[i].x, &AMP;A[I].Y, &a[i].z); } sort (A+1, a+n+1, CMP);  for(intI=1; i<=n; i++)        {             for(intj=1; j<i; J + +)            {                if(a[j].x<a[i].x && a[j].y<a[i].y&&a[j].z<a[i].z) {Maps[j][i]=1; }            }        }        intans=0;  for(intI=1; i<=n; i++) {memset (Vis,0,sizeof(VIS)); if(Find (i)) ans++; } printf ("%d\n", N-ans); }    return 0;}
View Code

Dolls---hdu4160 (maximum match)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.