【校内模拟7.30】—Ball(bitset)
大概想到了,结果没想到把条边拉出来排序一个个加
维护就完了
时间复杂度不会证
似乎是
但无论如何都卡不满
有点卡空间,压一压可以卡到
#include<bits/stdc++.h>
using namespace std;
#define gc getchar
inline int read(){
char ch=gc();
int res=0,f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
#define re register
#define pb push_back
#define cs const
#define fi first
#define se second
#define ll long long
cs int N=4005;
struct pt{
int x,y;
pt(int _x=0,int _y=0):x(_x),y(_y){}
friend inline pt operator +(cs pt &a,cs pt &b){
return pt(a.x+b.x,a.y+b.y);
}
friend inline pt operator -(cs pt &a,cs pt &b){
return pt(a.x-b.x,a.y-b.y);
}
friend inline int operator *(cs pt &a,cs pt &b){
return a.x*b.y-a.y*b.x;
}
friend inline pt operator /(cs pt &a,cs int b){
return pt(a.x/b,a.y/b);
}
inline int dis(){
return x*x+y*y;
}
}p[N];
bitset<N> v[N];
struct node{
short fi,se;int dis;
friend inline bool operator <(cs node &a,cs node &b){
return a.dis>b.dis;
}
};
vector<node> vec;
int n;
int main(){
n=read();
for(int i=1;i<=n;i++)p[i].x=read(),p[i].y=read();
for(int i=1;i<=n;i++)
for(int j=1;j<i;j++)vec.pb(node{i,j,(p[i]-p[j]).dis()});
sort(vec.begin(),vec.end());
for(node &x:vec){
if((v[x.fi]&v[x.se]).count()){printf("%.8lf",sqrt((p[x.fi]-p[x.se]).dis())/2);return 0;}
v[x.fi].set(x.se),v[x.se].set(x.fi);
}
}