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 sasnzy at 2006-09-01 08:38:40 on Problem 2983
In Reply To:本题不用并查集 直接用差分就可以了 另 Posted by:sasnzy at 2006-09-01 08:38:10
> 你这个并查集不是O(1)的算法 没有合并
> struct SET
> {
>    int p[maxn];
>    void init()
>    {
>      for (int i=0;i<maxn;i++) 
>        p[i]=i;
>    }
>    int find(int a)
>    {
>      if (a!=p[a]) p[a]=find(p[a]);
>      return p[a];
>    }
>    void merge(int a,int b)
>    {
>      p[find(b)]=find(a);
>    }
> 
> };

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