http://poj.org/problem?id=1270
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 2620 | Accepted: 986 |
Description
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
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
Output for different constraint specifications is separated by a blank line.
Sample Input
a b f g a b b f v w x y z v y x v z v w v
Sample Output
abfg abgf agbf gabf wxzvy wzxvy xwzvy xzwvy zwxvy zxwvy
Source
#include<iostream>
#include<algorithm>
using namespace std;
int indegree[20]={0};//入度数组
char vex[21];//节点数组
bool v[21]={0};//标记数组,标记节点是否已访问
int len;//节点个数
char stack[21];//存放结果的栈
int top=-1;
bool bian[21][21]={0};//存放边
void Iopo_Sort()//拓扑排序(递归)
{
}
int main()
{
}