#252. Sorting It All Out
Sorting It All Out
题目描述
有 n 个对象 A、B、…,依次加入 m 个形如 A<B 的大小关系。找出最早出现矛盾或足以唯一确定全部顺序的时刻。已经得到最终结论后,后续关系不改变所报告的最早时刻。
输入格式
多组 n、m;随后 m 行关系。n=m=0 时结束。
输出格式
若第 k 条后矛盾,输出 Inconsistency found after k relations.;若唯一确定,输出 Sorted sequence determined after k relations: ORDER.;否则输出 Sorted sequence cannot be determined.。
样例输入
4 6
A<B
A<C
B<C
C<D
B<D
A<B
3 2
A<B
B<A
26 1
A<Z
0 0
样例输出
Sorted sequence determined after 4 relations: ABCD.
Inconsistency found after 2 relations.
Sorted sequence cannot be determined.
题意整理;原题与输入输出格式对照。