当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1149:Structural Equivalence

题目描述
In programming language design circles, there has been much debate about the merits of "structural equivalence" vs. "name equivalence" for type matching. Pascal purports to have "name equivalence", but it doesn't; C purports to have structural equivalence, but it doesn't. Algol 68, the Latin of programming languages, has pure structural equivalence.
A simplified syntax for an Algol 68 type definition is as follows:

type_def -> type T = type_expr
type_expr -> T | int | real | char | struct ( field_defs )
field_defs -> T | field_defs T

In this syntax, T is a programmer-defined type name (in this problem, for simplicity, a single upper case letter). Plain text symbols appear literally in the input, and zero or more spaces may appear where there are spaces in the syntax.

Algol 68 type equivalence say that two types are equivalent if they are the same primitive type or they are both structures containing equivalent types in the same order.
输入解释
Input consists of several test cases. Each test case is a sequence of Algol 68 definitions, as described above, one per line. A line containing "-" separates test cases. A line containing "--" follows the last test case.
输出解释
The output for each case will consist of several lines; each line should contain a list of type names, all of which represent equivalent types. Each type name should appear on exactly one line of output, and the number of output lines should be minimized. The names in each list should be in alphabetical order; the lines of output should also be in alphabetical order. Output an empty line between test cases.
输入样例
type A = int
type B = A
type C = int
type X = struct(A B)
type Y = struct(B A)
type Z = struct(A Z)
type S = struct(A S)
type W = struct(B R)
type R = struct(C W)
--
输出样例
A B C
R S W Z
X Y
来自杭电HDUOJ的附加信息
Recommend Eddy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-1149

最后修改于 2020-10-25T22:42:30+00:00 由爬虫自动更新

共提交 150

通过率 64.0%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/32768K(Java/Others)