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 zjydhr at 2008-12-14 00:21:54 on Problem 3625
In Reply To:请教高手给个好算法! 我的Prim超时了... Posted by:MasterLuo at 2008-08-21 19:10:33
c=0;
    for(i=1;i<=n;i++)t[i]=jz[1][i];
    for(i=2;i<=n;i++)
    {
		m=10000000;
        for(k=1;k<=n;k++)
			if(m>t[k]&&t[k]!=-1){m=t[k];x=k;}
        c+=m;
        for(k=1;k<=n;k++)
			if(t[k]>jz[x][k])t[k]=jz[x][k];
    }

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