Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
33961 | LYLAKIOI | 【S】T1 | C++ | 通过 | 100 | 957 MS | 7292 KB | 1416 | 2024-10-30 20:06:26 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define pi pair<int,int> #define p1 first #define p2 second #define m_p make_pair #define p_b push_back using namespace std; typedef long long ll; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } const int maxn=1e5+10; int n; struct nd { int x,y; }d[maxn]; double calc(int i,int j){ double f1=(ll)(abs(d[i].x-d[j].x))+(ll)(abs(d[i].y-d[j].y)); double f2=sqrt((d[i].x-d[j].x)*1ll*(d[i].x-d[j].x)+(d[i].y-d[j].y)*1ll*(d[i].y-d[j].y)); return f1/f2; } bool operator<(nd a,nd b){ return a.x<b.x; } double cal(){ double res=1; set<pair<ll,int> >S; up(i,1,n){ auto it=S.lower_bound(m_p(d[i].x+d[i].y,0)); if(it!=S.end())res=max(res,calc(i,(*it).p2)); if(it!=S.begin())--it,res=max(res,calc(i,(*it).p2)); S.insert(m_p(d[i].x+d[i].y,i)); }return res; } void slv(){ n=read();up(i,1,n)d[i].x=read(),d[i].y=read(); double res=1; sort(d+1,d+n+1);res=max(res,cal()); up(i,1,n)d[i].y=-d[i].y;res=max(res,cal()); printf("%.10lf\n",res); } int main(){ int t=read();while(t--)slv(); fclose(stdin); fclose(stdout); return 0; }