UVA 124 & POJ 1270 Following Orders(拓扑排序)
2020-12-13 06:18
标签:algorithm 图论 拓扑排序 http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=60 http://poj.org/problem?id=1270
Description
Input
Output
Sample Input Sample Output Source 题意: 输入有两行,第一行给出若干出现的字母,第二行给出若干对关系x y,表示x 分析: 按字典序输出所有的拓扑序,和POJ 1128 & ZOJ
1083的方法一样,回溯求解即可,详情请戳这里: POJ 1128 & ZOJ 1083 Frame Stacking (拓扑排序) 这题的输入是比较恶心的,要注意写得鲁棒些。
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 3806
Accepted: 1507
This problem involves neither Zorn‘s Lemma nor fix-point semantics, but does involve order.
Given a list of variable constraints of the form x
For example, given the constraints x
All variables are single character, lower-case letters. There will be at least two variables, and no more than 20 variables in a specification. There will be at least one constraint, and no more than 50 constraints in a specification. There will be at least
one, and no more than 300 orderings consistent with the contraints in a specification.
Input is terminated by end-of-file.
Output for different constraint specifications is separated by a blank line. a b f g
a b b f
v w x y z
v y x v z v w v
abfg
abgf
agbf
gabf
wxzvy
wzxvy
xwzvy
xzwvy
zwxvy
zxwvy
/*
*
* Author : fcbruce
*
* Date : 2014-08-10 15:22:35
*
*/
#include
#include
文章标题:UVA 124 & POJ 1270 Following Orders(拓扑排序)
文章链接:http://soscw.com/essay/32823.html