MST , kruskal 直接跑 ---------------------------------------------------------------------- #include<cstdio> #include<algorithm> #include<vector> #include<cstring> #include<iostream> #define rep( i , n ) for( int i = 0 ; i <…
挺有意思的思路 如果不能自己打井,那么就是MST裸题了,考虑转换一下,自己打井就相当于连接一口虚拟的井(地下水?),所有井i到这口井的距离是w[i],这样把所有边排个序跑MST即可 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=305; int n,a[N][N],cnt,f[N],con,ans; struct qwe { int u,v…
题目背景 John的农场缺水了!!! 题目描述 Farmer John has decided to bring water to his N (1 <= N <= 300) pastures which are conveniently numbered 1..N. He may bring water to a pasture either by building a well in that pasture or connecting the pasture via a pipe to…