| ||||||||||
| 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..In Reply To::)谢谢. Posted by:MIBG at 2006-03-18 23:02:00 int Dijstra(int a, int b)
{
int i, j, mini, h, w;
int d[1001];
for(i = 0; i <= n; i++)
{
d[i] = 0;
flag[i] = 0;
}
d[a] = maxnum;
for(i = 0; i < n; i++)
{
mini = -1;
for(j = 1; j <= n; j++)
{
if(flag[j] == 0 && d[j] > 0)
{
mini = d[j];
h = j;
break;
}
}
if(mini == -1)break;
else flag[h] = 1;
for(j = 1; j <= n; j++)
{
if(flag[j] == 0 && matrix[h][j] != maxnum)
{
w = d[h] < matrix[h][j] ? d[h] : matrix[h][j];
d[j] = d[j] > w ? d[j] : w;
}
}
}
return d[b];
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator