1560_FollowingOrders

2022-5-16 18:17| 发布者: Hocassian| 查看: 46| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-2-89503971509500-Problem List-采集的数据-后羿采集器.html

Pro.ID

1560

Title

Following Orders

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=1560

AC

2

Submit

10

Ratio

20.00%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    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.

    输入

    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.

    输出

    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.

    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.

    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.

    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

    样例输入

    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

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部