Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这题的数据会不会是出了问题?

Posted by kingway at 2007-01-24 15:37:26 on Problem 1094
我的作法是每输入一个Relation,就做一次拓扑排序,如果排序输出的个数少于n,就说明出现的回环,结果为“Inconsistency",否则,如果所构成的网里是否只有一个点的入度为0和只有一个点的出度也为0,且改网是连通图,则结果是”Sorted sequence can be determined.“,否则继续,知道判断完最后一个Relation。

测试数据和运行结果如下:
4 4
A<B
C<D
B<C
D<A
4 6
A<B
A<C
B<C
A<A
C<D
B<D
4 6
A<C
B<C
B<A
C<D
B<D
D<A
4 3
A<B
C<D
D<C
4 3
A<B
C<B
B<D
5 5
A<B
B<D
C<B
D<E
E<D
3 2
A<B
B<A
26 1
A<Z
4 2
A<B
C<D
2 2
A<A
A<B
2 2
A<B
B<A
0 0

Sorted sequence determined after 3 relations: ABCD.
Inconsistency found after 4 relations.
Sorted sequence determined after 4 relations: BACD.
Inconsistency found after 3 relations.
Sorted sequence cannot be determined.
Inconsistency found after 5 relations.
Inconsistency found after 2 relations.
Sorted sequence cannot be determined.
Sorted sequence cannot be determined.
Inconsistency found after 1 relations.
Sorted sequence determined after 1 relations: AB.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator