翻译@@@

OpenJudge - 3529:Professor John

描述

Professor John is investigating a math problem. He has obtained some relations among several variables. Now he would like to know if there are any other relations that can be deduced from these obtained ones. For example, the known relations are given as follows: A < B, C > B and C < D, other relations including A < C, A < D and B < D can be deduced. Since he has been working for too long, Professor John decides to grant himself a vacation while assigning you to do the job. Are you ready?

输入

The first line of input contains an integer N, which is the number of test cases. Then N test cases follow. For each test case: the 1st line contains a positive integer m (<= 100) which is the number of given relations; the following m lines each contains a given relation, in the format Variable1 < Variable2 or Variable1 > Variable2
A "Variable" is represented by a capital character. There will not be conflicting relations given.

输出

For each test case, first print in one line "Case d:" where d is the number of the test case, start counting from 1. Then output all the relations which can be deduced from the given relations in alphabetical order, in the format Variable1 < Variable2. Each relation occupies one line. No extra space shall be printed. The given relations must NOT be included. If no new relation is found, output "NONE" in one line.

描述

约翰教授正在研究一道数学题。他得到了几个变量之间的一些关系。现在他想知道,是否有任何其他的关系可以从这些已知的关系中推断。例如,已知的关系如下所示:A<B,C>B和C<D,可以推导出包括A<C,A<D和B<D的其他关系。由于约翰教授工作时间太长,他决定给自己一个假期,同时指派你做这项工作。你准备好了吗?

输入

输入的第一行包含一个整数N,它是测试用例的数量。接下来是N个测试用例。对于每个测试用例:第一行包含一个正整数m(<=100),它是给定关系的数量;以下m行分别包含一个给定的关系,格式为Variable1<Variable2或Variable1>Variable2。“变量”由大写字母表示。不会有相互冲突的关系。

输出

对于每个测试用例,首先打印一行“case d:”其中d是测试用例的编号,从1开始计数。然后以Variable1<Variable2的格式,按字母顺序输出所有可以从给定关系推导出的关系。每个关系占用一行。不得打印额外的空间。给定的关系不能包括在内。如果没有找到新的关系,则在一行中输出“NONE”。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值