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

1次AC,说说思路吧。

Posted by huguang123 at 2009-04-10 09:35:38 on Problem 1308
用数组做太麻烦了,所以我用到了map(这是用来找环的,和判断是否一个子节点上面有两个父节
点),然后一个变量,du,记录所有点的入度,和一个变量ji用来记录点的个数,题目中每加入
一条边我们只需要判断这两个点是否相同,以及子节点是否已有父节点和是否成环,如果符合规
则,则改变du和ji的值,最后比较du+1?==ji,如果等于,就是树,否则就不是树。

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