HDU 4160 — Dolls 最小路径覆盖
来源:互联网 发布:淘宝商家可以看到买家 编辑:程序博客网 时间:2024/06/12 00:09
原题:http://acm.hdu.edu.cn/showproblem.php?pid=4160
题意:
有n个箱子,下面n行给出每个箱子的长、宽、高;
大箱子可以嵌套小箱子(要求长宽高均小于外面的箱子,且长宽高一一对应,即长对应长);
问露在外面箱子有几个;
思路:
1的体积小于2,2的体积小于3,那么3套2、2套1,就只有一个箱子3露在外面,可以想到是最小路径覆盖;
最小路径覆盖 = 顶点数-最大匹配数;
#include<stdio.h>#include<string.h>#include<vector>#include<algorithm>using namespace std;const int maxn = 550;int n;bool used[maxn];int match[maxn];vector<int>G[maxn];struct node{ int a, b, c;}box[maxn];bool find(int x){ for(int i = 0;i<G[x].size();i++) { int t = G[x][i]; if(!used[t]) { used[t] = true; if(match[t] == 0 || find(match[t])) { match[t] = x; return true; } } } return false;}int main(){ while(scanf("%d", &n) && n) { memset(match, 0, sizeof match); for(int i = 1;i<=n;i++) scanf("%d%d%d", &box[i].a, &box[i].b, &box[i].c); for(int i = 1;i<=n;i++) { G[i].clear(); for(int j = 1;j<=n;j++) { if(box[i].a<box[j].a && box[i].b<box[j].b && box[i].c<box[j].c) G[i].push_back(j); } } int sum = 0; for(int i = 1;i<=n;i++) { memset(used, false, sizeof used); if(find(i)) sum++; } printf("%d\n", n-sum); } return 0;}
,
0 0
- HDU 4160 — Dolls 最小路径覆盖
- hdu 4160 Dolls (最小路径覆盖)
- [hdu 4160] Dolls(最小路径覆盖)
- 【HDU】4160 Dolls 最小路径覆盖
- HDU 4160 Dolls(DAG最小路径覆盖)
- HDU 4160 Dolls 最小路径覆盖
- HDU 4160 Dolls(DAG最小路径覆盖)
- HDU 4160 Dolls(DAG最小路径覆盖)
- hdu 4160 Dolls 二分图最小路径覆盖
- hdu 4160 Dolls【最小路径覆盖----二分匹配】
- hdu 4160 dolls 最少路径覆盖
- hdu4160 Dolls【最小路径覆盖】
- HDU 4160 Dolls (最小路径覆盖=顶点数-最大匹配数)
- HDU 4160 Dolls(二分图匹配+匈牙利算法+最小路径覆盖)
- HDOJ 题目4160Dolls(二分图,最小路径覆盖)
- 【SPOJ-SCPC11H】Dolls【最小路径覆盖】
- 【最小路径覆盖】HDU 4160
- HDU - 4160 最小路径覆盖
- next数组介绍
- 黑马程序员———死锁
- tkinter菜单笔记=>持续更新
- 经典中的经典Unique Binary Search Trees II
- HALCON算子函数——Chapter 13 : Object
- HDU 4160 — Dolls 最小路径覆盖
- c语言中冒泡排序、插入排序、选择排序算法比较
- loadrunner解决用户名、密码不同问题
- 我的Android进阶之旅------>Android无第三方Jar包的源代报错:The current class path entry belongs to container ...的解决方法
- TableModel
- HALCON算子函数——Chapter 8 : Lines
- 黑马程序员———throws与throw区别
- [objective-c]推送警告处理
- KMP算法应用