上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 61 下一页
摘要: 操作系统上机实习课,简单地实现了一下银行家算法==具体的算法流程就不写了== 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<string> 5 #include<algorithm> 6 using namespace std; 7 #define n 5//进程个数 8 #define m 3//资源种类 9 string safety; 10 int Available[m]={2,3,3};//可用资源向量 11 int Reques 阅读全文
posted @ 2013-06-07 21:18 ihge2k 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4160思路:最小路径覆盖,如果满足条件:wi < wj , li < lj , and hi < hj,那么i->j连边,然后就是求最大匹配。最小路径覆盖=顶点数-最大匹配。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 struct Node{ 7 int wi 阅读全文
posted @ 2013-06-06 22:47 ihge2k 阅读(575) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3342思路:直接拓扑排序即可。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<queue> 6 #include<vector> 7 using namespace std; 8 bool map[111][111]; 9 vector<int>vet[111];10 int f 阅读全文
posted @ 2013-06-06 22:05 ihge2k 阅读(336) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2647思路:就是一个简单的拓扑排序,给每个节点标号,不过要注意的是访问过的节点的id应该取最大才能满足要求,然后就是要反向建边(这里wa了好多次)。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<queue> 6 #include<vector> 7 using namespace std; 阅读全文
posted @ 2013-06-06 21:44 ihge2k 阅读(496) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2458思路:由于要求选出尽可能多的认识的人,那么我们可以反着来考虑,给不认识的女孩和男孩连边,于是问题就转化为求最大独立集。最大独立集=顶点数-最大匹配。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<vector> 6 using namespace std; 7 #define MAXN 222 8 阅读全文
posted @ 2013-06-05 21:55 ihge2k 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4185思路:坐标映射建双向图,只要满足条件构成矩阵,就连边,最后求一下最大匹配即可。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<vector> 6 using namespace std; 7 #define MAXN 360036 8 vector<int>vet[MAXN]; 9 c 阅读全文
posted @ 2013-06-05 21:21 ihge2k 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1507思路:这题关键是建图,我们可以把坐标映射建双向图,最后求得的最大匹配数/2就ok了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<vector> 6 using namespace std; 7 #define MAXN 10010 8 vector<int>map[MAXN]; 9 阅读全文
posted @ 2013-06-05 20:51 ihge2k 阅读(614) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1350http://acm.hdu.edu.cn/showproblem.php?pid=1960思路:最小路径覆盖,即如果两条路线的时间不冲突,那么就连边,最后求一下最大匹配就可以了。最小路径覆盖=顶点数-最大匹配。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath> 6 #include&l 阅读全文
posted @ 2013-06-05 19:35 ihge2k 阅读(374) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2768思路:把喜欢cat的和喜欢dog的看成两个集合,如果这两个集合有冲突,即cat.love==dog.hate或者cat.hate==dog.love,这连边,代表有矛盾,那么最后的结果不就是求一下最大独立集吗。最大独立集=顶点数-最大匹配。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<string> 5 #include<algorithm&g 阅读全文
posted @ 2013-06-05 16:57 ihge2k 阅读(311) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1845思路:匈牙利算法应用,900ms+险过。(好像直接n/2就行) 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<vector> 6 using namespace std; 7 #define MAXN 5555 8 vector<int>map[MAXN]; 9 int n,m,ans 阅读全文
posted @ 2013-06-05 15:11 ihge2k 阅读(384) 评论(0) 推荐(0) 编辑
上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 61 下一页