SSL 1760商店選址問題

2021-10-14 04:49:20 字數 707 閱讀 6404

time limit:1000ms

memory limit:65536k

給出乙個城市的地圖(用鄰接矩陣表示),商店設在一點,使各個地方到商店距離之和最短。

第一行為n(共有幾個城市); n小於201

第二行至第n+1行為城市地圖(用鄰接矩陣表示);

最短路徑之和;

303

1302

120

3
用floyd。

0表示不能到達

#include

#include

#include

#include

#include

#include

#include

using

namespace std;

int n;

int a[

2010][

2010];

bool d[

2010];

void

input()

return;}

void

floyd()

//求多源最短路

intmain()

printf

("%d"

,ans)

;return0;

}

ssl1760 商店選址問題

商店選址問題 time limit 10000ms memory limit 65536k total submit 341 accepted 89 case time limit 1000ms description 給出乙個城市的地圖 用鄰接矩陣表示 商店設在一點,使各個地方到商店距離之和最短。...

SSL 1760 商店選址問題(最短路)

description 給出乙個城市的地圖 用鄰接矩陣表示 商店設在一點,使各個地方到商店距離之和最短。input 第一行為n 共有幾個城市 n小於201 第二行至第n 1行為城市地圖 用鄰接矩陣表示 output 最短路徑之和 sample input 3 0 3 1 3 0 2 1 2 0 sa...

SSLOJ1760 商店選址問題

給出乙個城市的地圖 用鄰接矩陣表示 商店設在一點,使各個地方到商店距離之和最短。第一行為n 共有幾個城市 n小於201 第二行至第n 1行為城市地圖 用鄰接矩陣表示 最短路徑之和 30 3 1 3 0 2 1 2 0 注意,0,代表到不了!剩下的floyd計算最短路,然後列舉求最小 code inc...