对于任意两个建筑物,以它们之间的最短路为边权求出最小生成树. 则询问(x,y)的答案为最小生成树上x到y路径上边权的最大值. BFS求出离每个点最近的建筑物以及到它的距离,可以发现只有交界处的边才有用,用这些边求MST即可. #include<cstdio> #include<algorithm> using namespace std; const int L=2010,N=200010,K=17,inf=~0U>>1; int H,W,n,m,Q,i,j,x,y,z…
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres using these two jugs. If z liters of water is measurable, you must…