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 |
第一次dijkstra成功本来以为我的程序是错的,一直调试……调试……过了一个多钟头后,没耐心了。于是把它提交一下试试,居然AC了。呵呵…… 给出我的关键代码: int dijkstra() { int i,j,m,d[MAX],x; CLR(visited); for(i = 1; i <= n; i ++) d[i]=(i==1?0:INT_MAX); for(i = 1; i <= n; i ++) { m = INT_MAX,x = 0; for(j = 1; j <= n; j ++) if(!visited[j] && m >= d[j]) x = j, m = d[j]; visited[x] = 1; for(j = 1; j <= n; j ++) if(mat[x][j] && d[j] > d[x]+mat[x][j]) d[j] = d[x]+mat[x][j]; } return m; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator