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的厉害,为什么呢?我也是PRIM算法啊

Posted by neu_dtbest at 2007-08-18 17:40:37 on Problem 1258
In Reply To:这个题目WA的厉害,为什么呢?我也是PRIM算法啊 Posted by:lwdlj at 2007-06-24 22:33:22
> #include<stdio.h>
> #include<stdlib.h>
> 
> int main()
> {
>     int a[101][101];
>     int n,i,j,k;
>     while(scanf("%d",&n)!=EOF)
>     {
>         int t[101],x;
>         __int64 c=0;
>         for(i=1;i<=n;i++)
>             for(j=1;j<=n;j++)
>                 scanf("%d",&a[i][j]);
>         for(i=1;i<=n;i++)t[i]=a[1][i];
>         for(i=2;i<=n;i++)
>         {
>             int m=65535;
>             for(k=1;k<=n;k++)
>                 if(m>t[k] && t[k]){m=t[k];x=k;}
>                 c+=m;t[x]=0;
>             for(k=1;k<=n;k++)
>                 if(t[k]>a[k][x])t[k]=a[k][x];
>         }
>         printf("%I64d\n",c);
>     }
>     //system("PAUSE");
>     return 0;
> }

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