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 |
我把我的代码发给您了In Reply To:Re:是不是没有disjoint? Posted by:frkstyc at 2005-04-09 09:52:30 > 无语了……找不到一个能去所有点的点就disjoint > void solve(void) > { > int i, j, k, m; > if(N == 1) > { > puts("1 0"); > return; > } > for(i = 0; i < N; i++) > { > for(j = 0; j < N; j++) > { > if(j != i) > { > for(k = 0; k < N; k++) > { > if(k != i && k != j) > { > int temp = dist[i][k] + dist[k][j]; > if(dist[i][k] > 0 && dist[k][j] > 0 && (dist[i][j] < 0 || dist[i][j] > temp)) > { > dist[i][j] = temp; > } > } > } > } > } > } > for(i = 0; i < N; i++) > { > for(j = 0; j < N; j++) > { > if(i != j && dist[i][j] < 0) > { > break; > } > } > if(j < N)//这个点不能所有点都去 > { > continue; > } > for(j = 0; j < N; j++) > { > if(j != i && dist[i][j] > dist[i][i]) > { > dist[i][i] = dist[i][j];//dist[i][i]记最小值 > } > } > } > k = -1; > m = 0x7FFFFFFF; > for(i = 0; i < N; i++) > { > if(dist[i][i] > 0 && dist[i][i] < m) > { > k = i; > m = dist[i][i]; > } > } > if(k >= 0) > { > printf("%d %d\n", k + 1, m); > } > else > { > puts("disjoint"); > } > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator