比赛 |
20120717 |
评测结果 |
PPTTTTTTTT |
题目名称 |
信使问题b |
最终得分 |
10 |
用户昵称 |
临轩听雨ゐ |
运行时间 |
4.000 s |
代码语言 |
C++ |
内存使用 |
5.81 MiB |
提交时间 |
2012-07-17 09:43:28 |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
struct In
{
long long x;
long long y;
}pic[100001];
double a=0.0,b=1000000.0;
int abs1(long long nn)
{
if(nn<0) return nn*(-1);
else return nn;
}
int main()
{
freopen ("postmanb.in","r",stdin);
freopen ("postmanb.out","w",stdout);
int n;
int i,j;
cin>>n;
for(i=1;i<=n;i++)
cin>>pic[i].x>>pic[i].y;
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
if(i!=j)
{
if(abs1(pic[i].x-pic[j].x)>abs1(pic[i].y-pic[j].y))
{
if(abs1(pic[i].y-pic[j].y)<b&&abs1(pic[i].y-pic[j].y)!=0)
b=abs1(pic[i].y-pic[j].y);
if(abs1(pic[i].y-pic[j].y)==0&&abs1(pic[i].x-pic[j].x)<b)
b=abs1(pic[i].x-pic[j].x);
}
if(abs1(pic[i].x-pic[j].x)<abs1(pic[i].y-pic[j].y))
{
if(abs1(pic[i].x-pic[j].x)<b&&abs1(pic[i].x-pic[j].x)!=0)
b=abs1(pic[i].x-pic[j].x);
if(abs1(pic[i].x-pic[j].x)==0&&abs1(pic[i].y-pic[j].y)<b)
b=abs1(pic[i].y-pic[j].y);
}
long double c,d;
c=abs1(pic[i].x-pic[j].x)*abs1(pic[i].x-pic[j].x);
d=abs1(pic[i].y-pic[j].y)*abs1(pic[i].y-pic[j].y);
if(sqrt(c+d)>a)
a=sqrt(c+d);
}
}
}
printf("%.4lf",a);
cout<<endl;
printf("%.4lf",b);
return 0;
}