
拓扑排序
文章平均质量分 50
Werky_blog
这个作者很懒,什么都没留下…
展开
-
hdu 1285 确定比赛名次(拓扑排序)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1285拓扑排序:给出一些小于关系,可以看做有向边#include#includeusing namespace std;const int maxn=505;int c[maxn];int ans[maxn],t,G[maxn][maxn],n,m;void toposort(){原创 2017-09-27 21:39:02 · 140 阅读 · 0 评论 -
hdu 2094 谁是冠军(STL,拓扑排序)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2094这题简直太水了,开始觉得拓扑,后来写着写着发现大部分代码没用,就删成这样了。只要入度唯一即可输出yesstl是真好用,特别是auto定义迭代器遍历map,set等。但是这题确实写错了,光写flag没判断入度均不为0时,应该是No,而之前写的忘判断flag==0时size是不是0;#原创 2017-09-29 21:46:03 · 329 阅读 · 0 评论 -
hdu 1811 Rank of Tetris (拓扑排序+并查集)
/*思路:相等的数可以看做一个,用并查集合并作为一个数。和儿子节点的边也都可以转化为和父节点的边。*/#include#include#include#includeusing namespace std;const int maxn=10005;int in[maxn],sum,n,m,X[maxn],Y[maxn],fa[maxn];vector G[maxn];原创 2017-09-28 22:52:26 · 200 阅读 · 0 评论 -
hdu 2647 Reward 拓扑排序(逆序)
题目:http://acm.split.hdu.edu.cn/showproblem.php?pid=2647只要让没有要求的那个人作为第一个入度为0的人即可。想多了,不用并查集,1 22 34 5这种情况仍然可以做出来的。#include#include#include#includeusing namespace std;const int maxn=1原创 2017-10-03 13:16:51 · 237 阅读 · 0 评论 -
hdu 3342 Legal or Not
题目:http://acm.split.hdu.edu.cn/showproblem.php?pid=3342拓扑排序找环即可。#include#include#include#includeusing namespace std;const int maxn=10005;int in[maxn],sum,n,m,X[maxn],Y[maxn],fa[maxn];vecto原创 2017-10-03 20:14:12 · 153 阅读 · 0 评论 -
POJ 3687 (拓扑排序,逆序,优先队列)
题目:http://poj.org/problem?id=3687是一个练习字典序输出,拓扑排序的好题,但考察的数据太没意思。输出的是位置而不是序列本身。。。大意:给了约束,a>b,其余按字典序输出。/*优先队列。*/#include#include#include#includeusing namespace std;const int maxn=205;int原创 2017-10-04 22:08:37 · 355 阅读 · 0 评论