//枚举选择的点,将剩余的点到它的距离排序后求和即可,复杂度n^2log(n)
#include
#include
#include
using namespace std;
const int maxn=105;
struct point{
int x,y;
void input(){ scanf("%d%d",&x,&y);}
}list[105];
int n,m;
int dist(point a,point b){
return abs(a.x-b.x)+abs(a.y-b.y);
}
void solve(){
int d[maxn],ct,ans=0x7f7f7f7f;
for(int i=0;i
int tmp=0;
for(int j=0;j
d[ct++]=dist(list[i],list[j]);
}
sort(d,d+ct);//排序
for(int j=0;j
}
printf("%d\n",ans);
}
int main(){
int ca;
scanf("%d",&ca);
while(ca--){
scanf("%d%d",&n,&m);
for(int i=0;i
}
return 0;
}
#include
#include
#include
main()
{
int x[103],y[103],i,j,k,dd[103],d[103],n,m,t,cas,min;
while(scanf("%d",&cas)!=EOF)
{
while(cas--)
{
scanf("%d%d",&n,&m);
for(i=0;i
for(i=0;i
for(j=0;j
dd[j]=abs(x[i]-x[j])+abs(y[i]-y[j]);
for(j=0;j
{
t=dd[j];dd[j]=dd[k];dd[k]=t;
}
d[i]=0;
for(j=0;j
}
min=d[0];
for(i=1;i
printf("%d\n",min);
}
}
}