| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:这个题目WA的厉害,为什么呢?我也是PRIM算法啊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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator