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

Re:并查集老是WA,哪位帮忙看下代码。。

Posted by yayu_myself at 2009-12-27 22:37:10 on Problem 1611
In Reply To:并查集老是WA,哪位帮忙看下代码。。 Posted by:yayu_myself at 2009-12-27 10:44:03
我把 

if (pre[a] > pre[b])
{
        pre[b] += pre[a];
        pre[a] = b;
}
else
{
	pre[a] += pre[b];
        pre[b] = a;		
}

改为

if( pre[a] < pre[b] )
{
	pre[a] += pre[b];
	pre[b] = a;
}
else 
{
	pre[b] += pre[a];
	pre[a] = b;
}

就过了。。郁闷死。。

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