app开发者平台在数字化时代的重要性与发展趋势解析
707
2022-08-29
hdu4160 Dolls
Problem Description Do you remember the box of Matryoshka dolls last week? Adam just got another box of dolls from Matryona. This time, the dolls have different shapes and sizes: some are skinny, some are fat, and some look as though they were attened. Specifically, doll i can be represented by three numbers wi, li, and hi, denoting its width, length, and height. Doll i can fit inside another doll j if and only if wi < wj , li < lj , and hi < hj . That is, the dolls cannot be rotated when fitting one inside another. Of course, each doll may contain at most one doll right inside it. Your goal is to fit dolls inside each other so that you minimize the number of outermost dolls.
Input The input consists of multiple test cases. Each test case begins with a line with a single integer N, 1 ≤ N ≤ 500, denoting the number of Matryoshka dolls. Then follow N lines, each with three space-separated integers wi, li, and hi (1 ≤ wi; li; hi ≤ 10,000) denoting the size of the ith doll. Input is followed by a single line with N = 0, which should not be processed.
Output For each test case, print out a single line with an integer denoting the minimum number of outermost dolls that can be obtained by optimally nesting the given dolls.
Sample Input 3 5 4 8 27 10 10 100 32 523 3 1 2 1 2 1 1 1 1 2 4 1 1 1 2 3 2 3 2 2 4 4 4 0
Sample Output 1 3 2
Source The 2011 Syrian Collegiate Programming Contest 最小路径覆盖问题 从源向每个节点的出点建边权为1的边 (因为只能做一回出点和入点)然后每个节点的的入点向汇建容量为1边 如果一个娃娃能覆盖另一个则从出点向入点建容量为1的边 然后跑dinic 即求出了最大匹配 初始的时候我认为我所有娃娃都得摆在外面 如果可以嵌套就就证明 这两个我可以变成一个 一个匹配我可以把两个点之间用一条边覆盖 就给连起来了 所以最后用总节点数-最大匹配即可
#include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~