还原加载网络(中石油6610 ) )。
弗洛伊德算法的使用。
#include iostream
using namespace std;
const int N=305;
int arr[N][N];
const int inf=1e9 10;
int main () )
{
int n;
wile(Cinn ) )。
{
for(intI=1; i=n; I )
for(intj=1; j=n; j )
{
cinarr[i][j];
}
for(intI=1; i=n; I )
龙龙sum=0;
for(intI=1; i=n; I )
for(intj=1; j=n; j )
for(inttemp=1; temp=n; temp )
{
intselect=(arr [ I ] [ temp ]==INF|| arr [ temp ] [ j ]==INF )? INF : (arr [ I ] [ temp ] arr [ temp ] [ j ] );
if(selectarr[I][j]arr[I][j]!=inf )
{
计数'-1 ' endl;
goto x;
}
//else if () )
}
for(intj=1; j=n; j )
for(intI=j1; i=n; I )
{
输入标志=0;
for(inttemp=1; temp=n; temp )
{
intselect=(arr [ I ] [ temp ]==INF|| arr [ temp ] [ j ]==INF )? INF : (arr [ I ] [ temp ] arr [ temp ] [ j ] );
if(select==arr[I][j] ) )
flag=1;
}
if(flag==0) )。
sum=sum arr[i][j];
}
coutsumendl;
x:
}
返回0;
}