poj 1270 Following Orders
来源:互联网 发布:2g网络接口 编辑:程序博客网 时间:2024/05/16 06:19
Following Orders
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 2194 Accepted: 794
Description
Order is an important concept in mathematics and in computer science. For example, Zorn's Lemma states: ``a partially ordered set in which every chain has an upper bound contains a maximal element.'' Order is also important in reasoning about the fix-point semantics of programs.
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 < y, you are to write a program that prints all orderings of the variables that are consistent with the constraints.
For example, given the constraints x < y and x < z there are two orderings of the variables x, y, and z that are consistent with these constraints: x y z and x z y.
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 < y, you are to write a program that prints all orderings of the variables that are consistent with the constraints.
For example, given the constraints x < y and x < z there are two orderings of the variables x, y, and z that are consistent with these constraints: x y z and x z y.
Input
The input consists of a sequence of constraint specifications. A specification consists of two lines: a list of variables on one line followed by a list of contraints on the next line. A constraint is given by a pair of variables, where x y indicates that x < y.
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.
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 each constraint specification, all orderings consistent with the constraints should be printed. Orderings are printed in lexicographical (alphabetical) order, one per line.
Output for different constraint specifications is separated by a blank line.
Output for different constraint specifications is separated by a blank line.
Sample Input
a b f ga b b fv w x y zv y x v z v w v
Sample Output
abfgabgfagbfgabfwxzvywzxvyxwzvyxzwvyzwxvyzxwvy
- POJ 1270 Following Orders
- poj 1270 Following Orders
- POJ 1270 Following Orders
- POJ-1270 Following Orders
- POJ 1270 Following Orders
- POJ 1270 Following Orders
- poj 1270 Following Orders
- poj 1270 Following Orders
- poj 1270 Following Orders
- POJ 1270 Following Orders
- POJ 1270 Following Orders
- POJ 1270 Following Orders
- poj 1270 Following Orders 拓扑
- POJ 1270 Following Orders 笔记
- POJ 1270 Following Orders (拓扑排序)
- POJ 1270 HOJ 1170 Following Orders
- POJ 1270 Following Orders 拓扑排序
- POJ 1270 Following Orders 拓扑排序
- 文件目录操作编程
- hdu 1051 Wooden Sticks 贪心
- hdu 2732 / poj 2711 Leapin' Lizards //拆点最大流
- POJ 1015
- shell脚本报错:"[: =: unary operator expected"
- poj 1270 Following Orders
- 中华唐氏小湾族2010年人口统计
- 使用vim插件 NERD_tree 阅读源码
- poj 3691
- MFC对话框程序基础复习005
- MFC对话框程序基础复习005
- 【已解决】zoj 3497 Mistwald 矩阵快速幂
- CVI--GUI界面--printf调试
- 天使投资人雷军