记录编号 |
32753 |
评测结果 |
AAAAAAAAAA |
题目名称 |
扩散 |
最终得分 |
100 |
用户昵称 |
苏轼 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.005 s |
提交时间 |
2011-11-08 08:12:02 |
内存使用 |
0.28 MiB |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;
int a[51],n,q[51][2],w[51][51],ji=0,answer=0;
bool used[51]={0};
int main()
{
freopen ("ppg.in","r",stdin);
freopen ("ppg.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++)
{
scanf("%d%d",&q[i][0],&q[i][1]);
}
for (int i=1;i<=n;i++)
{
for (int j=1;j<=n;j++)
{
int temp2;
temp2=(abs((double)q[i][0]-q[j][0])+abs((double)q[i][1]-q[j][1]));
if (temp2%2==1)
{
w[i][j]=temp2/2+1;
}
else
{
w[i][j]=temp2/2;
}
}
}
a[0]=1;
ji=1;
used[1]=1;
for (int k=1;k<n;k++)
{
int temp=2100000000;
int temp1;
for (int i=0;i<ji;i++)
{
int d=0;
int c=2100000000;
for (int j=1;j<=n;j++)
{
if (a[i]!=j&&!used[j])
{
if (w[a[i]][j]<c)
{
c=w[a[i]][j];
d=j;
}
}
}
if (c<temp)
{
temp=c;
temp1=d;
}
}
if (temp>answer)
{
answer=temp;
}
a[ji]=temp1;
used[temp1]=1;
ji++;
}
cout<<answer;
return 0;
}