Problem:
Problem K:
Trading Ship
You are on board a trading ship as a crew.
The ship is now going to pass through a strait notorious for many pirates often robbing ships. The Maritime Police has attempted to expel those pirates many times, but failed their attempts as the pirates are fairly strong. For this reason, every ship passing through the strait needs to defend themselves from the pirates.
The navigator has obtained a sea map on which the location of every hideout of pirates is shown. The strait is considered to be a rectangle of W × H on an xy-plane, where the two opposite corners have the coordinates of (0, 0) and (
W
,
H
). The ship is going to enter and exit the strait at arbitrary points on
y
= 0 and
y
=
H
respectively.
To minimize the risk of attack, the navigator has decided to take a route as distant from the hideouts as possible. As a talented programmer, you are asked by the navigator to write a program that finds the best route, that is, the route with the maximum possible distance to the closest hideouts. For simplicity, your program just needs to report the distance in this problem.
Input
The input begins with a line containing three integers
W
,
H
, and
N
. Here,
N
indicates the number of hideouts on the strait. Then
N
lines follow, each of which contains two integers
x
i
and
y
i
, which denote the coordinates the
i
-th hideout is located on.
The input satisfies the following conditions: 1 ≤
W
,
H
≤ 10
9
, 1 ≤
N
≤ 500, 0 ≤
x
i
≤
W
, 0 ≤
y
i
≤
H
.
Output
There should be a line containing the distance from the best route to the closest hideout(s). The distance should be in a decimal fraction and should not contain an absolute error greater than 10
-3
.
Sample Input and Output
Input #1
10 10 1
3 5
Output #1
7.000
Input #2
10 10 2
2 2
8 8
Output #2
4.243
Input #3
10 10 3
0 1
4 4
8 1
Output #3
2.500

Submitted solutions:

code_snippet: #include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<list>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define sgn(v) (abs((v))<eps?0:((v)<0?-1:1))
#define sqr(v) ((v)*(v))
#define MP make_pair
#define PB push_back
#define FI first
#define SE second
#define debug 0
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<double,int> PDI;
typedef pair<double,double> PDD;
typedef pair<int,int> PII;
typedef pair<int,LL> PIL;
typedef pair<LL,int> PLI;
typedef pair<LL,LL> PLL;
const double eps=1e-8;
const double pi=acos(-1);
const int maxn=505;
double x[maxn],y[maxn];
struct MST
{
	int mst[maxn];
	void init()
	{
		for(int i=0;i<maxn;++i)mst[i]=i;
	}
	int find(int x)
	{
		return mst[x]==x?x:mst[x]=find(mst[x]);
	}
	void fusion(int x,int y)
	{
		mst[find(x)]=find(y);
	}
}mst;
int w,h,n;
bool check(double r)
{
	int i,j;
	double len;
	mst.init();
	for(i=1;i<=n;++i)
	{
		if(sgn(x[i]-r)<0)mst.fusion(0,i);
		if(sgn(x[i]+r-w)>0)mst.fusion(n+1,i);
		for(j=1;j<i;++j)
		{
			len=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]));
			if(sgn(len-2*r)<0)
				mst.fusion(i,j);
		}
	}
	return mst.find(0)!=mst.find(n+1);
}
int main()
{
	int i;
	scanf("%d%d%d",&w,&h,&n);
	for(i=1;i<=n;++i)
		scanf("%lf%lf",&x[i],&y[i]);
	double l=0,r=1e12+100,mid;
	for(i=0;i<200;++i)
	{
		mid=(l+r)/2;
		if(check(mid))l=mid;
		else r=mid;
	}
	printf("%.3f\n",mid);
	return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 3580
final_rank: 5

code_snippet: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
#define MM(a) memset(a,0,sizeof(a))
double x[505],y[505],mi[505],ma[505],L,R,mid,w,h,dis;
int f[505],fa,fb,i,n,j,T;
int findfa(int o){
	if(f[o]==o)return o;
	return f[o]=findfa(f[o]);
}
bool check(){
	for(i=0;i<n;++i){
		mi[i]=x[i];
		ma[i]=x[i];
		f[i]=i;
	}
	for(i=0;i<n;++i){
		for(j=0;j<n;++j){
			fa=findfa(i);
			fb=findfa(j);
			if(fa==fb)continue;
			dis=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
			if(dis<4*mid*mid||fabs(dis-4*mid*mid)<1e-9){
				mi[fa]=min(mi[fa],mi[fb]);
				ma[fa]=max(ma[fa],ma[fb]);
				f[fb]=fa;
			}
		}
	}
	for(i=0;i<n;++i){
		fa=findfa(i);
		if((mi[fa]<mid||fabs(mi[fa]-mid)<1e-9)&&(ma[fa]+mid>w||fabs(ma[fa]+mid-w)<1e-9))return 0;
	}
	return 1;
}
int main(){
    scanf("%lf%lf%d",&w,&h,&n);
    for(i=0;i<n;++i){
    	scanf("%lf%lf",&x[i],&y[i]);
	}
	L=0;R=w*w+h*h;
	for(T=0;T<500;++T){
		mid=(L+R)/2;
		if(check()){
			L=mid;
		}else{
			R=mid;
		}
	}
	printf("%.3lf\n",L);
	return 0;
}
accuracy: 1
time_ms: 570
memory_kb: 3584
final_rank: 13

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;++i)
const int maxn = 510;
vector<int> mp[maxn];
long double dist[maxn][maxn],x[maxn],y[maxn];
int W,H,n,vis[maxn];
void makemap(double r){
	memset(vis,0,sizeof(vis));
	rep(i,1,n+2)mp[i].clear();
	rep(i,1,n)rep(j,i+1,n)if(sqrt(dist[i][j])<(r+r)){
		mp[i].push_back(j);
		mp[j].push_back(i);
	}
	rep(i,1,n){
		if(x[i]-r<0){
			mp[i].push_back(n+1);
			mp[n+1].push_back(i);
		}
		if(x[i]+r>(double)W){
			mp[i].push_back(n+2);
			mp[n+2].push_back(i);
		}
	}
}
bool dfs(int u){
	vis[u]=1;
	if(u==n+2)return true;
	for(int i=0;i<mp[u].size();++i){
		int v=mp[u][i];
		if(!vis[v]&&v!=u)
			if(dfs(v))return true;
	}
	return false;
}
int main(){
	cin>>W>>H>>n;
	rep(i,1,n){cin>>x[i]>>y[i];}
	rep(i,1,n)rep(j,i+1,n){dist[i][j]=dist[j][i]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);}
	double l=0,r=W;
	rep(ct,1,80){
		double m=(l+r)/2;
		makemap(m);
		if(dfs(n+1))r=m;
		else l=m;
	}
	printf("%.3lf\n",l );
	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 8780
final_rank: 12

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;++i)
const int maxn = 510;
vector<int> mp[maxn];
long double dist[maxn][maxn],x[maxn],y[maxn];
int W,H,n,vis[maxn];
void makemap(double r){
	memset(vis,0,sizeof(vis));
	rep(i,1,n+2)mp[i].clear();
	rep(i,1,n)rep(j,i+1,n)if(sqrt(dist[i][j])<(r+r)){
		mp[i].push_back(j);
		mp[j].push_back(i);
	}
	rep(i,1,n){
		if(x[i]-r<0){
			mp[i].push_back(n+1);
			mp[n+1].push_back(i);
		}
		if(x[i]+r>(double)W){
			mp[i].push_back(n+2);
			mp[n+2].push_back(i);
		}
	}
}
bool dfs(int u){
	vis[u]=1;
	if(u==n+2)return true;
	for(int i=0;i<mp[u].size();++i){
		int v=mp[u][i];
		if(!vis[v]&&v!=u)
			if(dfs(v))return true;
	}
	return false;
}
int main(){
	cin>>W>>H>>n;
	rep(i,1,n){cin>>x[i]>>y[i];}
	rep(i,1,n)rep(j,i+1,n){dist[i][j]=dist[j][i]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);}
	double l=0,r=W;
	rep(ct,1,80){
		double m=(l+r)/2;
		makemap(m);
		if(dfs(n+1))r=m;
		else l=m;
	}
	printf("%.5lf\n",l );
	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 8764
final_rank: 11

code_snippet: // AOJ #2478 Trading Ship
// 2025.2.20

#include <bits/stdc++.h>
using namespace std;

struct Point { int x, y; };

struct DSU {
    vector<int> parent;
    DSU(int n) : parent(n) {
        for (int i = 0; i < n; i++) parent[i] = i;
    }
    int find(int a) {
        return parent[a] == a ? a : parent[a] = find(parent[a]);
    }
    void unite(int a, int b) {
        a = find(a);
        b = find(b);
        if(a != b) parent[b] = a;
    }
};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int W, H, N;
    cin >> W >> H >> N;
    vector<Point> hideouts(N);
    for (int i = 0; i < N; i++) cin >> hideouts[i].x >> hideouts[i].y;
    
    double lo = 0.0, hi = max(W, H) * 1.0;
    
    for (int iter = 0; iter < 50; iter++){
        double mid = (lo + hi) / 2.0;
        
        int total = N + 2;
        int leftBoundary = N;
        int rightBoundary = N+1;
        DSU dsu(total);
        
        for (int i = 0; i < N; i++){
            if(hideouts[i].x - mid <= 0) dsu.unite(i, leftBoundary);
            if(hideouts[i].x + mid >= W) dsu.unite(i, rightBoundary);
        }
        
        for (int i = 0; i < N; i++){
            for (int j = i+1; j < N; j++){
                long long dx = hideouts[i].x - hideouts[j].x;
                long long dy = hideouts[i].y - hideouts[j].y;
                if( (double)dx*dx + (double)dy*dy <= 4.0 * mid * mid ){
                    dsu.unite(i, j);
                }
            }
        }
        
        if(dsu.find(leftBoundary) == dsu.find(rightBoundary)) hi = mid;
        else lo = mid;
    }
    cout << fixed << setprecision(6) << lo << endl;
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3592
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);

	int w, _, n;
	cin >> w >> _ >> n;
	vector<double> x(n), y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	auto chk = [&](double r) -> bool {
		vector<int> vst(n);
		queue<int> qu;
		for (int i = 0; i < n; i++) {
			if (x[i] < r) {
				qu.push(i);
				vst[i] = 1;
			}
		}
		while (!qu.empty()) {
			int c = qu.front(); qu.pop();
			if (w - x[c] < r) return true;
			for (int i = 0; i < n; i++) {
				if (vst[i]) continue;
				if (hypot(x[c] - x[i], y[c] - y[i]) < 2 * r) {
					qu.push(i);
					vst[i] = 1;
				}
			}
		}
		return false;
	};
	double lo = 0, hi = 1e9;
	for (int i = 0; i < 200; i++) {
		double mid = (lo + hi) / 2;
		if (chk(mid)) hi = mid;
		else lo = mid;
	}
	cout << fixed << setprecision(4) << lo << '\n';
	return 0;
}
accuracy: 1
time_ms: 330
memory_kb: 3584
final_rank: 10

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE  505

struct Point{

	double x,y;
};


int N;
double W,H;
int boss[SIZE],height[SIZE];
Point point[SIZE];


int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

void init(){

	for(int i = 0; i < N; i++){

		boss[i] = i;
		height[i] = 0;
	}
}

double calc_dist(Point A,Point B){

	return (A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y);
}


bool is_OK(double R){

	init();

	//左端
	for(int i = 1; i <= N-2; i++){

		if(point[i].x < R){
			unite(0,i);
		}
	}

	//右端
	for(int i = 1; i <= N-2; i++){

		if(point[i].x > W-R){
			unite(N-1,i);
		}
	}


	for(int i = 1; i <= N-3; i++){
		for(int k = i+1; k <= N-2; k++){

			if(calc_dist(point[i],point[k]) < 4*R*R){

				unite(i,k);
			}
		}
	}

	return get_boss(0) != get_boss(N-1); //左端と右端が違うグループならOK
}

int main(){

	scanf("%lf %lf %d",&W,&H,&N);

	for(int i = 1; i <= N; i++){

		scanf("%lf %lf",&point[i].x,&point[i].y);
	}

	N += 2;

	double L = 0,R = W,mid = (L+R)/2;
	double ans = 0;

	for(int i = 0; i < 50; i++){

		if(is_OK(mid)){

			ans = mid;
			L = mid+EPS; //より長く

		}else{

			R = mid-EPS; //より短く
		}
		mid = (L+R)/2;
	}

	printf("%.10lf\n",ans);

	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3264
final_rank: 1

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE  505

struct Point{

	double x,y;
};


int N;
int W,H;
int boss[SIZE],height[SIZE];
Point point[SIZE];


int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

void init(){

	for(int i = 0; i < N; i++){

		boss[i] = i;
		height[i] = 0;
	}
}

double calc_dist(Point A,Point B){

	return (A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y);
}


bool is_OK(double R){

	init();

	//左端
	for(int i = 1; i <= N-2; i++){

		if(point[i].x < R){
			unite(0,i);
		}
	}

	//右端
	for(int i = 1; i <= N-2; i++){

		if(point[i].x > W-R){
			unite(N-1,i);
		}
	}


	for(int i = 1; i <= N-3; i++){
		for(int k = i+1; k <= N-2; k++){

			if(calc_dist(point[i],point[k]) < 4*R*R){

				unite(i,k);
			}
		}
	}

	int num_group = 0;
	for(int i = 0; i < N; i++){
		if(i == get_boss(i)){

			num_group++;
		}
	}

	return num_group != 1;
}

int main(){

	scanf("%d %d %d",&W,&H,&N);

	for(int i = 1; i <= N; i++){

		scanf("%lf %lf",&point[i].x,&point[i].y);
	}

	N += 2;

	double L = 0,R = W,mid = (L+R)/2;
	double ans = 0;

	for(int i = 0; i < 100; i++){

		if(is_OK(mid)){

			ans = mid;
			L = mid+EPS; //より長く

		}else{

			R = mid-EPS; //より短く
		}
		mid = (L+R)/2;
	}

	printf("%.10lf\n",ans);

	return 0;
}
accuracy: 0.11320754716981132
time_ms: 10
memory_kb: 3224
final_rank: 17

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE  505

struct Point{

	bool operator<(const struct Point &arg) const{

		if(fabs(x-arg.x) > EPS){

			return x < arg.x;
		}else{

			return y < arg.x;
		}
	}
	double x,y;
};


int N;
int W,H;
int boss[SIZE],height[SIZE];
Point point[SIZE];


int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

void init(){

	for(int i = 0; i < N; i++){

		boss[i] = i;
		height[i] = 0;
	}
}

double calc_dist(Point A,Point B){

	return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}


bool is_OK(double R){

	if(point[0].x > R+EPS)return true; //左端
	if(point[N-1].x < W-(R+EPS))return true; //右端

	init();

	for(int i = 0; i < N-1; i++){
		for(int k = i+1; k < N; k++){

			if(calc_dist(point[i],point[k]) <= 2*R){

				unite(i,k);
			}
		}
	}

	int num_group = 0;
	for(int i = 0; i < N; i++){
		if(i == get_boss(i)){

			num_group++;
		}
	}

	return num_group != 1;
}

int main(){

	scanf("%d %d %d",&W,&H,&N);

	for(int i = 0; i < N; i++){

		scanf("%lf %lf",&point[i].x,&point[i].y);
	}

	sort(point,point+N);

	double L = 0,R = W,mid = (L+R)/2;
	double ans = 0;

	for(int i = 0; i < 100; i++){

		if(is_OK(mid)){

			ans = mid;
			L = mid+EPS; //より長く

		}else{

			R = mid-EPS; //より短く
		}
		mid = (L+R)/2;
	}

	printf("%.10lf\n",ans);

	return 0;
}
accuracy: 0.11320754716981132
time_ms: 40
memory_kb: 3216
final_rank: 18

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

using R = long double; // Rにmint渡せるようにする
using P = complex<R>;
using L = pair<P,P>;
using G = vector<P>;
struct C {
    P c; R r;
    C() {}
    C(const P &a, const R &b) : c(a), r(b) {}
};
struct S : public L {
    S() {}
    S(const P &a, const P &b) : L(a,b) {}
};

const R EPS = 1e-8;
const R PI = atan(1)*4;

inline int sgn(const R& r) { return (r>EPS) - (r<-EPS); }
inline R dot(const P& a, const P& b) {
    return real(a)*real(b) + imag(a)*imag(b);
}
inline R det(const P& a, const P& b) {
    return real(a)*imag(b) - imag(a)*real(b);
}
inline P rotate(const P& p, const R& arg) {
    return P(cos(arg)*p.real()-sin(arg)*p.imag(),
             sin(arg)*p.real()+cos(arg)*p.imag());
}
inline P vec(const L& l) {return l.second - l.first;}
namespace std {
	bool operator < (const P& a, const P& b) {
		return sgn(real(a-b)) ? real(a-b) < 0 : sgn(imag(a-b)) < 0;
	}
	bool operator == (const P& a, const P& b) {
		return sgn(real(a-b)) == 0 && sgn(imag(a-b)) == 0;
	}
    bool cmp_y (const P& a, const P& b) {
        return sgn(imag(a-b)) ? imag(a-b) < 0 : sgn(real(a-b)) < 0;
    }
}

// P,L,Sについて入力
inline istream& operator>>(istream& is, P& p) {
    R x, y;
    is >> x >> y;
    p = P(x, y);
    return is;
}
inline istream& operator>>(istream& is, L& l) {
    P a, b;
    is >> a >> b;
    l = L(a, b);
    return is;
}
inline istream& operator>>(istream& is, S& s) {
    P a, b;
    is >> a >> b;
    s = S(a, b);
    return is;
}

// 線分abから見たcの位置
enum CCW{LEFT=1, RIGHT=2, BACK=4, FRONT=8, ON_SEG=16};
int ccw(P a, P b, P c) {
	P p = (c-a)/(b-a);
	if(sgn(imag(p)) > 0) return LEFT;
	if(sgn(imag(p)) < 0) return RIGHT;
	if(sgn(real(p)) < 0) return BACK;
	if(sgn(real(p)-1) > 0) return FRONT;
	return ON_SEG;
}

// 射影
P inline projection(const L &l, const P &p) {
    R t = dot(p-l.first, l.first-l.second) / norm(l.first-l.second);
    return l.first + t*(l.first-l.second);
}

R dist(const L& l, const P& p) {
    P q = projection(l, p);
    return abs(p-q);
}

// 交差
int intersect(const C& c, const L& l) {
    R d = dist(l, c.c);
    // cout << l << " " << d << endl;
    if(sgn(c.r-d) > 0) return 2; // 交差している
    else if(sgn(c.r-d) == 0) return 1; // 接している
    return 0; // 交差しない
}
int intersect(const C& a, const C& b) {
	R dist = norm(a.c-b.c), r1 = (a.r+b.r)*(a.r+b.r), r2 = (a.r-b.r)*(a.r-b.r);
	if(sgn(r1-dist) < 0)  return 4;	// 円が離れている
	if(sgn(r1-dist) == 0) return 3;	// 外接
	if(sgn(r2-dist) < 0 && sgn(dist-r1) < 0) return 2; // 交差
	if(sgn(dist-r2) == 0) return 1; // 内接
	return 0;	// 内部に含む
}

struct visualizer {
    struct Col { int r, g, b; };
    FILE* fp;
    R off, f;
    visualizer(string s, R d, R u) : off(d), f(1000/(u-d)) {
        fp = fopen(s.c_str(), "w");
        fprintf(
            fp,
            "<html><head><script>"
            "onload = function draw() {"
            "var cv = document.getElementById('c');"
            "var ct = cv.getContext('2d');"
        );
    }
    R norm(R x) { return (x - off) * f; }
    void set_col(Col c) {
        fprintf(fp, "ct.fillStyle = \"rgb(%d, %d, %d)\";", c.r, c.g, c.b);
        fprintf(fp, "ct.strokeStyle = \"rgb(%d, %d, %d)\";", c.r, c.g, c.b);
    }
    void line(L l, Col col = {0, 0, 0}) {
        set_col(col);
        fprintf(fp,
        "ct.beginPath();"
        "ct.moveTo(%Lf, %Lf);"
        "ct.lineTo(%Lf, %Lf);"
        "ct.closePath();"
        "ct.stroke();",
        norm(l.first.real()), norm(l.first.imag()), norm(l.second.real()), norm(l.second.imag()));
    }
    void point(P p, Col col = {0, 0, 0}) {
        set_col(col);
        fprintf(fp,
            "ct.beginPath();"
            "ct.arc(%Lf, %Lf, 2, 0, Math.PI * 2, true);"
            "ct.fill();",
            norm(p.real()), norm(p.imag())
        );
    }
    ~visualizer() {
        fprintf(
            fp,
            "}</script></head><body>"
            "<canvas id=\"c\" width=\"1000\" height=\"1000\">"
            "</canvas></body></html>"
        );
        fclose(fp);
    }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll h, w, n;
    cin >> w >> h >> n;
    vector<P> v(n);
    REP(i, n) cin >> v[i];

    // visualizer vis("test.html", 0, max(h, w));
    // REP(i, n) vis.point(v[i], {255,0,0});
    // vis.line(L(P(0,0),P(0,h)));
    // vis.line(L(P(0,0),P(w,0)));
    // vis.line(L(P(w,h),P(0,h)));
    // vis.line(L(P(w,h),P(w,0)));
    // return 0;

    auto check = [&](R mid) {
        vector<C> c(n);
        REP(i, n) c[i] = C(v[i], mid);
        vector<vector<ll>> g(n+2);
        REP(i, n) FOR(j, i+1, n) {
            if(intersect(c[i], c[j]) == 2) {
                g[i].push_back(j);
                g[j].push_back(i);
            }
        }
        REP(i, n) {
            L left(P(0,0),P(0,h));
            if(intersect(c[i], left) == 2) {
                g[i].push_back(n);
                g[n].push_back(i);
            }
            L right(P(w,0),P(w,h));
            if(intersect(c[i], right) == 2) {
                g[n+1].push_back(i);
                g[i].push_back(n+1);
            }
        }

        queue<int> que;
        que.push(n);
        vector<int> dist(n+2, INF);
        dist[n] = 0;
        while(que.size()) {
            int t = que.front(); que.pop();
            for(auto to: g[t]) {
                if(dist[to] == INF) {
                    dist[to] = dist[t] + 1;
                    que.push(to);
                }
            }
        }

        // cout << dist << endl;
        return dist[n+1] == INF;
    };

    // cout << check(4000000) << endl;

    R lb = 0, ub = 2e9;
    REP(i, 100) {
        R mid = (lb+ub)/2;
        // cout << lb << " " << mid << " " << ub << endl;
        if(check(mid)) lb = mid;
        else ub = mid;
    }

    cout << fixed << setprecision(5) << lb << endl;

    return 0;
}
accuracy: 1
time_ms: 530
memory_kb: 5276
final_rank: 15

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

using R = long double; // Rにmint渡せるようにする
using P = complex<R>;
using L = pair<P,P>;
using G = vector<P>;
struct C {
    P c; R r;
    C() {}
    C(const P &a, const R &b) : c(a), r(b) {}
};
struct S : public L {
    S() {}
    S(const P &a, const P &b) : L(a,b) {}
};

const R EPS = 1e-8;
const R PI = atan(1)*4;

inline int sgn(const R& r) { return (r>EPS) - (r<-EPS); }
inline R dot(const P& a, const P& b) {
    return real(a)*real(b) + imag(a)*imag(b);
}
inline R det(const P& a, const P& b) {
    return real(a)*imag(b) - imag(a)*real(b);
}
inline P rotate(const P& p, const R& arg) {
    return P(cos(arg)*p.real()-sin(arg)*p.imag(),
             sin(arg)*p.real()+cos(arg)*p.imag());
}
inline P vec(const L& l) {return l.second - l.first;}
namespace std {
	bool operator < (const P& a, const P& b) {
		return sgn(real(a-b)) ? real(a-b) < 0 : sgn(imag(a-b)) < 0;
	}
	bool operator == (const P& a, const P& b) {
		return sgn(real(a-b)) == 0 && sgn(imag(a-b)) == 0;
	}
    bool cmp_y (const P& a, const P& b) {
        return sgn(imag(a-b)) ? imag(a-b) < 0 : sgn(real(a-b)) < 0;
    }
}

// P,L,Sについて入力
inline istream& operator>>(istream& is, P& p) {
    R x, y;
    is >> x >> y;
    p = P(x, y);
    return is;
}
inline istream& operator>>(istream& is, L& l) {
    P a, b;
    is >> a >> b;
    l = L(a, b);
    return is;
}
inline istream& operator>>(istream& is, S& s) {
    P a, b;
    is >> a >> b;
    s = S(a, b);
    return is;
}

// 線分abから見たcの位置
enum CCW{LEFT=1, RIGHT=2, BACK=4, FRONT=8, ON_SEG=16};
int ccw(P a, P b, P c) {
	P p = (c-a)/(b-a);
	if(sgn(imag(p)) > 0) return LEFT;
	if(sgn(imag(p)) < 0) return RIGHT;
	if(sgn(real(p)) < 0) return BACK;
	if(sgn(real(p)-1) > 0) return FRONT;
	return ON_SEG;
}

// 射影
P inline projection(const L &l, const P &p) {
    R t = dot(p-l.first, l.first-l.second) / norm(l.first-l.second);
    return l.first + t*(l.first-l.second);
}

R dist(const L& l, const P& p) {
    P q = projection(l, p);
    return abs(p-q);
}

// 交差
int intersect(const C& c, const L& l) {
    R d = dist(l, c.c);
    // cout << l << " " << d << endl;
    if(sgn(c.r-d) > 0) return 2; // 交差している
    else if(sgn(c.r-d) == 0) return 1; // 接している
    return 0; // 交差しない
}
int intersect(const C& a, const C& b) {
	R dist = norm(a.c-b.c), r1 = (a.r+b.r)*(a.r+b.r), r2 = (a.r-b.r)*(a.r-b.r);
	if(sgn(r1-dist) < 0)  return 4;	// 円が離れている
	if(sgn(r1-dist) == 0) return 3;	// 外接
	if(sgn(r2-dist) < 0 && sgn(dist-r1) < 0) return 2; // 交差
	if(sgn(dist-r2) == 0) return 1; // 内接
	return 0;	// 内部に含む
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll h, w, n;
    cin >> h >> w >> n;
    vector<P> v(n);
    REP(i, n) cin >> v[i];

    auto check = [&](R mid) {
        vector<C> c(n);
        REP(i, n) c[i] = C(v[i], mid);
        vector<vector<ll>> g(n+2);
        REP(i, n) FOR(j, i+1, n) {
            if(intersect(c[i], c[j]) == 2) {
                g[i].push_back(j);
                g[j].push_back(i);
            }
        }
        REP(i, n) {
            L left(P(0,0),P(0,h));
            if(intersect(c[i], left) == 2) {
                g[i].push_back(n);
                g[n].push_back(i);
            }
            L right(P(w,0),P(w,h));
            if(intersect(c[i], right) == 2) {
                g[n+1].push_back(i);
                g[i].push_back(n+1);
            }
        }

        // REP(i, n+2) cout << g[i] << endl;

        queue<int> que;
        que.push(n);
        vector<int> dist(n+2, INF);
        dist[n] = 0;
        while(que.size()) {
            int t = que.front(); que.pop();
            for(auto to: g[t]) {
                if(dist[to] == INF) {
                    dist[to] = dist[t] + 1;
                    que.push(to);
                }
            }
        }

        return dist[n+1] == INF;
    };

    // cout << check(100) << endl;

    R lb = 0, ub = 2e9;
    REP(i, 100) {
        R mid = (lb+ub)/2;
        // cout << lb << " " << mid << " " << ub << endl;
        if(check(mid)) lb = mid;
        else ub = mid;
    }

    cout << fixed << setprecision(5) << lb << endl;

    return 0;
}
accuracy: 0.16981132075471697
time_ms: 530
memory_kb: 5448
final_rank: 16

code_snippet: #include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;

bool eq(ld a, ld b) {
	return (abs(a - b) < eps);
}

class Line {
public:
	Point a, b;
};
class Circle {
public:
	Point p; ld r;
};

ld dot(Point a, Point b) {
	return real(conj(a)*b);
}
ld cross(Point a, Point b) {
	return imag(conj(a)*b);
}
namespace std {
	bool operator<(const Point &lhs, const Point &rhs) {
		return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag() : lhs.real() < rhs.real();
	}
}
Point proj(Line l, Point p) {
	ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + t * (l.a - l.b);
}

ld dist_lp(Line l, Point p) {
	return abs(p - proj(l, p));
}

int ccw(Point a, Point b, Point c) {
	b -= a; c -= a;
	if (cross(b, c) > eps)return 1;//a,b,cが反時計回り
	if (cross(b, c) < -eps)return -1;//a,b,cが時計回り
	if (dot(b, c) < 0)return 2;//c,a,bの順に一直線
	if (norm(b) < norm(c))return -2;//a,b,cの順に一直線
	return 0;//a,c,bの順に一直線
}
bool isis_ll(Line l, Line m) {
	return !eq(cross(l.b - l.a, m.b - m.a), 0);
}
Point is_ll(Line s, Line t) {
	Point sv = s.b - s.a; Point tv = t.b - t.a;
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

//直線lに幅dをつける
vector<Line> make_w(Line l, ld d) {
	Point dif = l.b - l.a;
	dif = dif*Point{0, 1};
	dif = dif * (d / abs(dif));
	vector<Line> ret;
	for (int id = 1; id >= -1; id -= 2) {
		Point a = l.a + dif * (ld)id;
		Point b = l.b + dif * (ld)id;
		ret.push_back({ a,b });
	}
	return ret;
}

typedef vector<Point> polygon;
polygon ConvexHull(polygon p) {
	int n = p.size();
	int k = 0;
	sort(p.begin(), p.end());
	polygon ch(2 * n);
	for (int i = 0; i < n; ch[k++] = p[i++]) {
		while (k >= 2 && ccw(ch[k - 2], ch[k - 1], p[i]) <= 0)--k;
	}
	for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = p[i--]) {
		while (k >= t && ccw(ch[k - 2], ch[k - 1], p[i]) <= 0)--k;
	}
	ch.resize(k - 1);
	return ch;
}
polygon convex_cut(const polygon &p, Line l) {
	vector<Point> ret;
	rep(i, p.size()) {
		Point a = p[i], b = p[(i + 1) % p.size()];
		if (ccw(l.a, l.b, a) != -1)ret.push_back(a);
		if (ccw(l.a, l.b, a)*ccw(l.a, l.b, b)<0) {
			ret.push_back(is_ll({ a,b }, l));
		}
	}
	return ret;
}
ld area(const polygon &p){
	ld ret = 0;
	int n = p.size();
	rep(j, n)ret += cross(p[j], p[(j + 1) % n]);
	return ret / 2.0;
}
ld max_distance(const polygon &p) {
	//assert(p.size()>1);
	polygon g = ConvexHull(p);
	int n = g.size(), a = 0, b = 1;
	ld ret = abs(g[0] - g[1]);
	while (a < n) {
		Point p1 = g[a%n], p2 = g[(a + 1) % n];
		Point q1 = g[b%n], q2 = g[(b + 1) % n];
		if (arg((p2 - p1) / (q1 - q2)) > 0)++b; else ++a;
		ret = max(ret, abs(p1 - q1));
	}
	return ret;
}

vector<Point> is_cc(Circle c1, Circle c2) {
	vector<Point> res;
	ld d = abs(c1.p - c2.p);
	ld rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2 * d);
	ld dfr = c1.r*c1.r - rc * rc;
	if (abs(dfr) < eps)dfr = 0.0;
	if (dfr < 0.0)return res;
	ld rs = sqrt(dfr);
	Point diff = (c2.p - c1.p) / d;
	res.push_back(c1.p + diff * Point(rc, rs));
	if (dfr != 0.0)res.push_back(c1.p + diff * Point(rc, -rs));
	return res;
}
bool in_Circle(Circle a, Circle b) {
	ld dist = abs(b.p - a.p);
	return dist < b.r - a.r+eps;
}

ll gcd(ll x, ll y) {
	x = abs(x), y = abs(y);
	if (x < y)swap(x, y);
	while (y) {
		ll r = x % y; x = y; y = r;
	}
	return x;
}

//0/0だけ気を付けて！
struct ratio {
	ll a, b;
	ratio(ll x) { a = x; b = 1; };
	ratio(ll x, ll y) {
		a = x; b = y;
		ll g = gcd(x, y);
		if (g > 0) {
			a /= g, b /= g;
			if (b < 0)a = -a, b = -b;
		}
	};

};

void normalize(ratio &r) {
	ll g = gcd(r.a, r.b);
	r.a /= g; r.b /= g;
	if (r.b < 0)r.b = -r.b, r.a = -r.a;
}
bool operator<(const ratio &x, const ratio &y) {
	return x.a*y.b < x.b*y.a;
}
bool operator==(const ratio &x, const ratio &y) {
	return x.a*y.b == x.b*y.a;
}

bool isis_cc(Circle a, Circle b) {
	ld dist = abs(b.p - a.p);
	return dist < a.r + b.r;
}
ld w, h; int n;
void solve() {
	cin >> w >> h >> n;
	vector<Point> p(n);
	rep(i, n) {
		ld a, b; cin >> a >> b;
		p[i] = { a,b };
	}
	ld le = 0, ri = mod;
	rep(aa, 100) {
		//cout << le << " " << ri << endl;
		ld mid = (le + ri) / 2.0;
		vector<Circle> c(n);
		vector<vector<int>> G(n+2);
		int s = n, t = n + 1;
		rep(i, n) {
			c[i] = { p[i],mid };
		}
		rep(i, n) {
			rep(j, i) {
				if (isis_cc(c[i], c[j])) {
					G[i].push_back(j);
					G[j].push_back(i);
				}
			}
			if (real(p[i]) < mid) {
				G[s].push_back(i);
			}
			if (w - real(p[i]) < mid) {
				G[i].push_back(t);
			}
		}
		vector<bool> used(n+2, false);
		used[s] = true;
		queue<int> q; q.push(s);
		while (!q.empty()) {
			int id = q.front(); q.pop();
			rep(j, G[id].size()) {
				int to = G[id][j];
				if (!used[to]) {
					used[to] = true; q.push(to);
				}
			}
		}
		if (used[t]) {
			ri = mid;
		}
		else {
			le = mid;
		}
	}
	cout << le << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(3);
	/*while (cin >> n>>k, n) {
		solve();
	}*/
	solve();
	//stop
	return 0;
}
accuracy: 1
time_ms: 510
memory_kb: 4212
final_rank: 14

code_snippet: #include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}

namespace Geometry{
    typedef long double D;
    typedef complex<long double> P;
    typedef pair<P,D> C;
    
    const D EPS=1e-9;
    const D PI=asin(1)*2;
    const D INF=1e18;
    
    const static bool comp(const P &p1,const P &p2){return p1.real()==p2.real()?p1.imag()<p2.imag():p1.real()<p2.real();}
    
    D dot(P p1,P p2){return p1.real()*p2.real()+p1.imag()*p2.imag();}
    
    D cross(P p1,P p2){return p1.real()*p2.imag()-p1.imag()*p2.real();}
    
    P project(P vec,P x){return vec*(x/vec).real();}
    
    P project(P p1,P p2,P x){return p1+project(p2-p1,x-p1);}
    
    P reflect(P vec,P x){return vec*conj(x/vec);}
    
    P reflect(P p1,P p2,P x){return p1+reflect(p2-p1,x-p1);}
    
    bool intersectSL(P p1,P p2,P vec){vec/=abs(vec); p1/=vec; p2/=vec; return (p1.imag()<EPS && p2.imag()>-EPS) || (p1.imag()>-EPS && p2.imag()<EPS);}
    
    bool intersectSL(P p1,P p2,P p3,P p4){return intersectSL(p1-p4,p2-p4,p3-p4);}
    
    bool intersectSS(P p1,P p2,P p3,P p4){return (dot(p2-p1,p3-p1)<-EPS && dot(p2-p1,p4-p1)<-EPS) || (dot(p1-p2,p3-p2)<-EPS && dot(p1-p2,p4-p2)<-EPS)?false:intersectSL(p1,p2,p3,p4) && intersectSL(p3,p4,p1,p2);}
    
    D distLP(P vec,P x){return abs((x/vec).imag())*abs(vec);}
    
    D distLP(P p1,P p2,P x){return distLP(p2-p1,x-p1);}
    
    D distSP(P p1,P p2,P x){return dot(p2-p1,x-p1)<-EPS?abs(x-p1):dot(p1-p2,x-p2)<-EPS?abs(x-p2):distLP(p1,p2,x);}
    
    D distSS(P p1,P p2,P p3,P p4){return intersectSS(p1,p2,p3,p4)?0.0:min(min(distSP(p1,p2,p3),distSP(p1,p2,p4)),min(distSP(p3,p4,p1),distSP(p3,p4,p2)));}
    
    P crosspointLL(P p1,P p2,P vec){return abs(cross(p2-p1,vec))<EPS?vec:vec*cross(p2-p1,p2)/cross(p2-p1,vec);}
    
    P crosspointLL(P p1,P p2,P p3,P p4){return p4+crosspointLL(p1-p4,p2-p4,p3-p4);}
    
    P crosspointSS(P p1,P p2,P p3,P p4){return distSP(p1,p2,p3)<EPS?p3:distSP(p1,p2,p4)<EPS?p4:crosspointLL(p1,p2,p3,p4);}
    
    bool intersectShL(P p1,P p2,P vec){vec/=abs(vec); return intersectSL(p1,p2,vec) && crosspointLL(p1/vec,p2/vec,vec/vec).real()>-EPS;}
    
    bool intersectShL(P p1,P p2,P p3,P p4){return intersectShL(p1-p3,p2-p3,p4-p3);}
    
    //1::in,0::on edge,-1::out
    int contain(const vector<P> &poly,const P &p){
        vector<P> A={{65537,96847},{-24061,6701},{56369,-86509},{-93763,-78049},{56957,10007}};
        vector<bool> cnt(5,false);
        for(int i=1;i<=poly.size();i++){
            if(distSP(poly[i-1],poly[i%poly.size()],p)<EPS){return 0;}
            for(int j=0;j<5;j++){
                if(intersectShL(poly[i-1],poly[i%poly.size()],p,p+A[j])){cnt[j]=!cnt[j];}
            }
        }
        int in=0;
        for(int j=0;j<5;j++){if(cnt[j]){in++;}}
        return in>=3?1:-1;
    }
    
    vector<P> convexcut(const vector<P> &poly,P p1,P p2){
        vector<P> ret;
        for(int i=1;i<=poly.size();i++){
            if(cross(p2-p1,poly[i-1]-p1)>-EPS){ret.push_back(poly[i-1]);}
            if(intersectSL(poly[i-1],poly[i%poly.size()],p1,p2) && distLP(p1,p2,poly[i-1])>EPS && distLP(p1,p2,poly[i%poly.size()])>EPS){ret.push_back(crosspointLL(poly[i-1],poly[i%poly.size()],p1,p2));}
        }
        return ret;
    }
    
    D area(const vector<P> &poly){
        D ans=0;
        for(int i=2;i<poly.size();i++){ans+=cross(poly[i-1]-poly[0],poly[i]-poly[0]);}
        return abs(ans)/2;
    }
    
    vector<P> convexhull(vector<P> pts){
        vector<P> ret;
        sort(pts.begin(),pts.end(),comp);
        for(auto &I:pts){
            if(!ret.empty() && I==ret.back()){continue;}
            while(ret.size()>=2 && cross(ret.back()-ret[ret.size()-2],I-ret.back())<-EPS){ret.pop_back();}
            ret.push_back(I);
        }
        reverse(pts.begin(),pts.end());
        for(auto &I:pts){
            if(!ret.empty() && I==ret.back()){continue;}
            while(ret.size()>=2 && cross(ret.back()-ret[ret.size()-2],I-ret.back())<-EPS){ret.pop_back();}
            ret.push_back(I);
        }
        if(ret[0]==ret.back()){ret.pop_back();}
        return ret;
    }
    
    //4::seperate,3::circumscribe,2::intersect,1::inscribe,0::contain,-1::same
    int intersectCC(C c1,C c2){
        D d=abs(c1.F-c2.F),r=c1.S+c2.S,dif=abs(c2.S-c1.S);
        if(d<EPS && dif<EPS){return -1;}
        if(d-r>EPS){return 4;}
        if(d-r>-EPS){return 3;}
        if(d-dif>EPS){return 2;}
        if(d-dif>-EPS){return 1;}
        return 0;
    }
    
    vector<P> crosspointLC(P p1,P p2,C c){
        vector<P> ret;
        P pr=project(p1,p2,c.F);
        D d=distLP(p1,p2,c.F);
        if(d-c.S>EPS){return ret;}
        if(d-c.S>-EPS){ret.push_back(pr); return ret;}
        P vec=p2-p1; vec*=sqrt(c.S*c.S-d*d)/abs(vec);
        ret.push_back(pr-vec);
        ret.push_back(pr+vec);
        return ret;
    }
    
    vector<P> crosspointSC(P p1,P p2,C c){
        vector<P> ret;
        for(auto &I:crosspointLC(p1,p2,c)){if(distSP(p1,p2,I)<EPS){ret.push_back(I);}}
        return ret;
    }
    
    vector<P> crosspointCC(C c1,C c2){
        vector<P> ret;
        P vec=c2.F-c1.F;
        D base=(c1.S*c1.S+norm(vec)-c2.S*c2.S)/(2*abs(vec));
        D h=sqrt(c1.S*c1.S-base*base);
        vec/=abs(vec);
        ret.push_back(c1.F+vec*P(base,-h));
        ret.push_back(c1.F+vec*P(base,h));
        return ret;
    }
    
    vector<P> tangentCP(C c,P p){return crosspointCC(c,C(p,sqrt(norm(c.F-p)-c.S*c.S)));}
    
    vector<pair<P,P>> tangentCC(C c1,C c2){
        vector<pair<P,P>> ret;
        P d=c2.F-c1.F;
        for(D i:{-1,1}){
            D r=c1.S+c2.S*i;
            if(intersectCC(c1,c2)>i+1){
                for(P s:{-1i,1i}){
                    P p=r+s*sqrt(norm(d)-norm(r));
                    ret.push_back({c1.F+d*c1.S/norm(d)*p,c2.F-d*i*c2.S/norm(d)*p});
                }
            }
        }
        return ret;
    }
    
    D area(const vector<P> &poly,C c){
        D ret=0;
        for(int i=0;i<poly.size();i++){
            P a=poly[i]-c.F,b=poly[(i+1)%poly.size()]-c.F;
            if(abs(a)<c.S+EPS && abs(b)<c.S+EPS){ret+=cross(a,b);}
            else{
                vector<P> A=crosspointSC(a,b,{0,c.S});
                if(A.empty()){ret+=c.S*c.S*arg(b/a);}
                else{
                    ret+=(abs(a)<c.S?cross(a,A[0]):c.S*c.S*arg(A[0]/a));
                    ret+=(abs(b)<c.S?cross(A.back(),b):c.S*c.S*arg(b/A.back()));
                    ret+=cross(A[0],A.back());
                }
            }
        }
        return abs(ret)/2;
    }
    
    //反時計回り
    D diameter(const vector<P> &poly){
        D ret=0;
        ll l=0,r=0,n=poly.size();
        if(n==2){return abs(poly[0]-poly[1]);}
        for(int i=0;i<n;i++){
            if(comp(poly[l],poly[i])){l=i;}
            if(comp(poly[i],poly[r])){r=i;}
        }
        ll sl=r,sr=l;
        while(sl!=l || sr!=r){
            ret=max(ret,abs(poly[r]-poly[l]));
            if(cross(poly[(l+1)%n]-poly[l],poly[(r+1)%n]-poly[r])<0){(++l)%=n;}
            else{(++r)%=n;}
        }
        return ret;
    }
    
    D closestpair(vector<P> pt){
        sort(pt.begin(),pt.end(),comp);
        D ret=INF;
        for(ll i=1;i<pt.size();i<<=1){
            for(ll j=0;i+j<pt.size();j+=i*2){
                ll m=i+j;
                vector<P> R;
                D l=-INF,r=INF;
                for(ll k=j;k<m;k++){l=max(l,pt[k].real());}
                for(ll k=0;m+k<pt.size() && k<i;k++){r=min(r,pt[m+k].real());}
                for(ll k=0;m+k<pt.size() && k<i;k++){if(pt[m+k].real()-l<ret){R.push_back(pt[m+k]);}}
                ll idx=0;
                for(ll k=j;k<m;k++){
                    if(r-pt[k].real()>ret){continue;}
                    while(idx<R.size() && pt[k].imag()-R[idx].imag()>ret){idx++;}
                    for(ll n=idx;n<R.size() && R[n].imag()-pt[k].imag()<ret;n++){ret=min(ret,abs(R[n]-pt[k]));}
                }
                inplace_merge(pt.begin()+j,pt.begin()+m,j+i*2<pt.size()?pt.begin()+j+2*i:pt.end(),[](const P &a,const P &b){return a.imag()==b.imag()?a.real()<b.real():a.imag()<b.imag();});
            }
        }
        return ret;
    }
    
    istream & operator >> (istream &i,P &p){D x,y; i>>x>>y; p={x,y}; return i;}
    istream & operator >> (istream &i,C &p){D x,y; i>>x>>y>>p.S; p.F={x,y}; return i;}
};

using namespace Geometry;

D w,h;
ll n;

bool judge(vector<P> &A,D x){
    vector<bool> used(n,false);
    queue<ll> Q;
    for(int i=0;i<n;i++){
        if(A[i].real()<x){used[i]=true; Q.push(i);}
    }
    while(!Q.empty()){
        ll w=Q.front(); Q.pop();
        for(int i=0;i<n;i++){
            if(!used[i] && abs(A[w]-A[i])<2*x){used[i]=true; Q.push(i);}
        }
    }
    for(int i=0;i<n;i++){
        if(used[i] && A[i].real()>w-x){return false;}
    }
    return true;
}


int main(){
    cin>>w>>h>>n;
    vector<P> A(n);
    cin>>A;
    D l=0,r=1e18;
    for(int i=0;i<100;i++){
        D m=(l+r)/2;
        if(judge(A,m)){l=m;}
        else{r=m;}
    }
    cout<<fixed<<setprecision(3)<<l<<endl;
    return 0;
}
accuracy: 1
time_ms: 300
memory_kb: 3388
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;

const double e=0.000003;

struct point{
	double x,y;
}a[501];

bool cmp(point a,point b){
	return a.y<b.y;
}

double work(point a,point b){
	double dis;
	dis=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
	return dis;
}

int f[505];

int find(int k){
	return f[k]!=k?find(f[k]):f[k];
}

int w,h,n;



double low,high;


int main(){
	scanf("%d%d%d",&w,&h,&n);
	for(int i=1;i<=n;i++)	scanf("%lf%lf",&a[i].y,&a[i].x);	
	high=2e9;
	low=0;
	while(high>=low+1e-4){
		double mid=(high+low)/2;
		for(int i=1;i<=n+4;i++){
			f[i]=i;
		}
		for(int i=1;i<=n;i++){
			if(a[i].y<mid) f[find(i)]=n+1;
			if(w-a[i].y<mid) f[find(i)]=n+2;
		}
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				if(work(a[i],a[j])<2*mid){
					f[find(i)]=find(j);
				}
			}
		}
		if(find(1+n)==find(n+2)){
			high=mid;
		}
		else low=mid;
	}
	printf("%.3lf",(low+high)/2);
	return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3252
final_rank: 4

code_snippet: #include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <map>
#include <queue>
using namespace std;
const double EPS = 1e-6;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()
 
typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};
 
namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}
 
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}
 
bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}
bool intersectSS(const L& a, const L& b){
    return ( ccw(a[0],a[1],b[0]) *ccw(a[0],a[1],b[1]) <= 0 ) &&
        ( ccw(b[0],b[1],a[0]) *ccw(b[0],b[1],a[1]) <= 0 );
}

double distanceLP(const L &l, const P &p) {
    return abs(cross(l[1]-l[0], p-l[0])) /abs(l[1]-l[0]);
}
double distanceSP(const L &s, const P &p) {
    if(dot(s[1]-s[0], p-s[0]) < EPS) return abs(p-s[0]);
    if(dot(s[0]-s[1], p-s[1]) < EPS) return abs(p-s[1]);
    return distanceLP(s, p);
}
 
bool isParallel(const P &a, const P &b){
    return abs(cross(a,b)) < EPS;
}
bool isParallel(const L &a, const L &b){
    return isParallel(a[1]-a[0], b[1]-b[0]);
}
P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}
 
double getarea(const VP &poly){
    double ret = 0;
    for (int i=0; i<(int)poly.size(); i++){ 
        ret += cross(poly[i], poly[(i+1)%poly.size()]);
    }
    return ret*0.5;
}
int in_poly(const P &p, const VP &poly){
    int n = poly.size();
    int ret = -1;
    for(int i=0; i<n; i++){
        P a = poly[i]-p;
        P b = poly[(i+1)%n]-p;
        if(a.Y > b.Y) swap(a,b);
        if(intersectSP(L(a,b), P(0,0))) return 0;
        if(a.Y<=0 && b.Y>0 && cross(a,b)<0) ret = -ret;
    }
    return ret;
}
 
VP convex(VP v){
    VP ret;
    int n = v.size();
    sort(v.begin(), v.end());
    for(int i=0; i<n; i++){
        while((int)ret.size()>1 && cross(ret.back()-ret[ret.size()-2], v[i]-ret.back()) < EPS){
            ret.pop_back();
        }
        ret.push_back(v[i]);
    }
    int t = ret.size();
    for(int i=n-2; i>=0; i--){
        while((int)ret.size()>t && cross(ret.back()-ret[ret.size()-2], v[i]-ret.back()) < EPS){
            ret.pop_back();
        }
        ret.push_back(v[i]);
    }
    if((int)ret.size() > 1) ret.pop_back();
    return ret;
}
 
VP convex_cut(const VP& p, const L& l){
    VP ret;
    int n = p.size();
    for(int i=0; i<n; i++){
        P curr = p[i];
        P next = p[(i+1)%n];
        if(ccw(l[0], l[1], curr) != -1) ret.push_back(curr);
        if(ccw(l[0], l[1], curr) *ccw(l[0], l[1], next) == -1){
            ret.push_back(crosspointLL(L(curr, next), l));
        }
    }
    return ret;
}
 
vector<VP> volonoi_division(VP plist, VP poly){
    int m = plist.size();
    vector<VP> ret(m);
    if(m == 1){
        ret.push_back(poly);
        return ret;
    }
    for(int i=0; i<m; i++){
        VP v = poly;
        for(int j=0; j<m; j++){
            if(i==j) continue;
            P mid = (plist[i] +plist[j]) /2.0;
            L bisector(mid, mid +(plist[j]-plist[i])*P(0,1));
            v = convex_cut(v, bisector);
        }
        ret[i] = v;
    }
    return ret;
}
 
int main(){
    int w,h,n;
    cin >> w >> h >> n;
    VP sq{P(0, 0), P(w, 0), P(w, h), P(0, h)};
    VP plist(n);
    for(int i=0; i<n; i++){
        int x,y;
        cin >> x >> y;
        plist[i] = P(x, y);
    }
    vector<VP> polys = volonoi_division(plist, sq);

    vector<L> edge;
    for(const VP &poly: polys){
        int m = poly.size();
        for(int i=0; i<m; i++){
            L e(poly[i], poly[(i+1)%m]);
            if(e[1] < e[0]) swap(e[0], e[1]);
            edge.push_back(e);
        }
    }
    sort(edge.begin(), edge.end());
    edge.erase(unique(edge.begin(), edge.end()), edge.end());
    map<P, int> conv;
    int count = 0;
    for(const L &e: edge){
        for(int d=0; d<2; d++){
            if(conv.count(e[d]) == 0){
                conv[e[d]] = count;
                count++;
            }
        }
    }
 
    vector<vector<pair<int, double> > > adj(count);
    for(const L &e: edge){
        int idx0 = conv[e[0]];
        int idx1 = conv[e[1]];
        double dist = INF;
        if(!EQ(e[0].Y, e[1].Y) || (!EQ(e[0].Y, 0) && !EQ(e[0].Y, h))){
            for(const P &p: plist){
                dist = min(dist, distanceSP(e, p));
            }
        }
        adj[idx0].emplace_back(idx1, dist);
        adj[idx1].emplace_back(idx0, dist);
    }

    int sidx = conv[P(0, 0)];
    int gidx = conv[P(w, h)];
    priority_queue<pair<double, int> > wait;
    wait.push(make_pair(INF, sidx));
    vector<double> maxdist(adj.size(), 0);
    maxdist[sidx] = INF;
    while(!wait.empty()){
        double dist = wait.top().first;
        int pos = wait.top().second;
        wait.pop();
        if(dist +EPS < maxdist[pos]) continue;
        if(pos == gidx) break;
        for(const pair<int, double> &next: adj[pos]){
            int npos = next.first;
            double ndist = min(dist, next.second);
            if(ndist > maxdist[npos] +EPS){
                maxdist[npos] = ndist;
                wait.push(make_pair(ndist, npos));
            }
        }
    }
    cout << fixed << setprecision(10);
    cout << maxdist[gidx] << endl;
    return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 3612
final_rank: 6

code_snippet: #include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <map>
#include <queue>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()
 
typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};
 
namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}
 
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}
 
bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}
bool intersectSS(const L& a, const L& b){
    return ( ccw(a[0],a[1],b[0]) *ccw(a[0],a[1],b[1]) <= 0 ) &&
        ( ccw(b[0],b[1],a[0]) *ccw(b[0],b[1],a[1]) <= 0 );
}

double distanceLP(const L &l, const P &p) {
    return abs(cross(l[1]-l[0], p-l[0])) /abs(l[1]-l[0]);
}
double distanceSP(const L &s, const P &p) {
    if(dot(s[1]-s[0], p-s[0]) < EPS) return abs(p-s[0]);
    if(dot(s[0]-s[1], p-s[1]) < EPS) return abs(p-s[1]);
    return distanceLP(s, p);
}
 
bool isParallel(const P &a, const P &b){
    return abs(cross(a,b)) < EPS;
}
bool isParallel(const L &a, const L &b){
    return isParallel(a[1]-a[0], b[1]-b[0]);
}
P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}
 
double getarea(const VP &poly){
    double ret = 0;
    for (int i=0; i<(int)poly.size(); i++){ 
        ret += cross(poly[i], poly[(i+1)%poly.size()]);
    }
    return ret*0.5;
}
int in_poly(const P &p, const VP &poly){
    int n = poly.size();
    int ret = -1;
    for(int i=0; i<n; i++){
        P a = poly[i]-p;
        P b = poly[(i+1)%n]-p;
        if(a.Y > b.Y) swap(a,b);
        if(intersectSP(L(a,b), P(0,0))) return 0;
        if(a.Y<=0 && b.Y>0 && cross(a,b)<0) ret = -ret;
    }
    return ret;
}
 
VP convex(VP v){
    VP ret;
    int n = v.size();
    sort(v.begin(), v.end());
    for(int i=0; i<n; i++){
        while((int)ret.size()>1 && cross(ret.back()-ret[ret.size()-2], v[i]-ret.back()) < EPS){
            ret.pop_back();
        }
        ret.push_back(v[i]);
    }
    int t = ret.size();
    for(int i=n-2; i>=0; i--){
        while((int)ret.size()>t && cross(ret.back()-ret[ret.size()-2], v[i]-ret.back()) < EPS){
            ret.pop_back();
        }
        ret.push_back(v[i]);
    }
    if((int)ret.size() > 1) ret.pop_back();
    return ret;
}
 
VP convex_cut(const VP& p, const L& l){
    VP ret;
    int n = p.size();
    for(int i=0; i<n; i++){
        P curr = p[i];
        P next = p[(i+1)%n];
        if(ccw(l[0], l[1], curr) != -1) ret.push_back(curr);
        if(ccw(l[0], l[1], curr) *ccw(l[0], l[1], next) == -1){
            ret.push_back(crosspointLL(L(curr, next), l));
        }
    }
    return ret;
}
 
VP convex_intersect(VP a, VP b){
    VP plist;
    int n=a.size(), m=b.size();
    for(int r=0; r<2; r++){
        for(int i=0; i<n; i++){
            if(in_poly(a[i], b) >= 0){
                plist.push_back(a[i]);
            }
        }
        swap(n, m);
        swap(a, b);
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            L la(a[i], a[(i+1)%n]), lb(b[j], b[(j+1)%m]);
            if(!isParallel(la, lb) && intersectSS(la, lb)){
                plist.push_back(crosspointLL(la, lb));
            }
        }
    }
    return convex(plist);
}
 
vector<VP> volonoi_division(VP plist, VP poly){
    int m = plist.size();
    vector<VP> ret(m);
    if(m == 1){
        ret.push_back(poly);
        return ret;
    }
    for(int i=0; i<m; i++){
        VP v = poly;
        for(int j=0; j<m; j++){
            if(i==j) continue;
            P mid = (plist[i]+plist[j])/2.0;
            L bisector(mid, mid +(plist[j]-plist[i])*P(0,1));
            VP cut = convex_cut(v, bisector);
            v = convex_intersect(v, cut);
        }
        ret[i] = v;
    }
    return ret;
}
 
int main(){
    int w,h,n;
    cin >> w >> h >> n;
    VP sq{P(0, 0), P(w, 0), P(w, h), P(0, h)};
    VP plist(n);
    for(int i=0; i<n; i++){
        int x,y;
        cin >> x >> y;
        plist[i] = P(x, y);
    }
    vector<VP> polys = volonoi_division(plist, sq);

    vector<L> edge;
    for(const VP &poly: polys){
        int m = poly.size();
        for(int i=0; i<m; i++){
            L e(poly[i], poly[(i+1)%m]);
            if(e[1] < e[0]) swap(e[0], e[1]);
            edge.push_back(e);
        }
    }
    sort(edge.begin(), edge.end());
    edge.erase(unique(edge.begin(), edge.end()), edge.end());
    map<P, int> conv;
    int count = 0;
    for(const L &e: edge){
        for(int d=0; d<2; d++){
            if(conv.count(e[d]) == 0){
                conv[e[d]] = count;
                count++;
            }
        }
    }
 
    vector<vector<pair<int, double> > > adj(count);
    for(const L &e: edge){
        int idx0 = conv[e[0]];
        int idx1 = conv[e[1]];
        double dist = INF;
        if(!EQ(e[0].Y, e[1].Y) || (!EQ(e[0].Y, 0) && !EQ(e[0].Y, h))){
            for(const P &p: plist){
                dist = min(dist, distanceSP(e, p));
            }
        }
        adj[idx0].emplace_back(idx1, dist);
        adj[idx1].emplace_back(idx0, dist);
    }

    int sidx = conv[P(0, 0)];
    int gidx = conv[P(w, h)];
    priority_queue<pair<double, int> > wait;
    wait.push(make_pair(INF, sidx));
    vector<double> maxdist(adj.size(), 0);
    maxdist[sidx] = INF;
    while(!wait.empty()){
        double dist = wait.top().first;
        int pos = wait.top().second;
        wait.pop();
        if(dist +EPS < maxdist[pos]) continue;
        if(pos == gidx) break;
        for(const pair<int, double> &next: adj[pos]){
            int npos = next.first;
            double ndist = min(dist, next.second);
            if(ndist > maxdist[npos] +EPS){
                maxdist[npos] = ndist;
                wait.push(make_pair(ndist, npos));
            }
        }
    }
    cout << fixed << setprecision(10);
    cout << maxdist[gidx] << endl;
    return 0;
}
accuracy: 0.11320754716981132
time_ms: 760
memory_kb: 3748
final_rank: 20

code_snippet: #include<bits/stdc++.h>
using namespace std;


typedef complex<double> P;
typedef pair<P,P> L;

const double EPS = 1e-8;

double dot(P a, P b){
  return a.real() * b.real() + a.imag() * b.imag();
}
double cross(P a,P b){
  return a.real() * b.imag() - a.imag() * b.real();
}

struct Circle {
  P c;
  double r;
  Circle( P c=P(0,0), double r=0):c(c),r(r){}
};

P proj( P p, L l ) {
  return l.first + dot( p-l.first, l.second-l.first ) /
    norm( l.second - l.first ) * (l.second - l.first );
}

bool isIntersectLS( L l, L s ){
  return cross( l.second - l.first, s.first- l.first ) *
    cross( l.second - l.first, s.second - l.first ) < EPS;
}

bool isIntersectSP(L s, P p){
  return abs( s.first - p ) + abs( s.second - p ) - abs( s.second - s.first ) < EPS;
}



vector<P> getIntersectCS( Circle c, L s ) {
  vector<P> res;
  P h = proj( c.c, s );
  double d = abs( c.c - h );
  if( d > c.r + EPS );
  else if( d > c.r - EPS ) {
    if( isIntersectSP( s, h ) )
      res.push_back( h );
  } else {
    P v = s.second - s.first;
    v = (sqrt( c.r * c.r - d*d ) / abs( v ) ) * v;
    if( isIntersectSP( s, h+v ) ) res.push_back( h+v );
    if( isIntersectSP( s, h-v ) ) res.push_back( h-v );
    return res;
  }
}

vector<P> tangent( Circle c, P p ) {
  vector<P> res;
  double a = abs( p - c.c );
  if( a < c.r - EPS );
  else if( a < c.r + EPS ) res.push_back( p );
  else {
    double b = sqrt( a*a - c.r*c.r );
    double psi = arg( p - c.c );
    double phi = M_PI - acos( b/a );
    res.push_back( p + b * P(cos(psi+phi), sin(psi+phi)) );
    res.push_back( p + b * P(cos(psi-phi), sin(psi-phi)) );
  }
  return res;    
}

vector<L> tangentCC( Circle p, Circle q ) {
  double pr = p.r, qr = q.r;
  P pc = p.c, qc = q.c;
  double d = abs( pc - qc ), dr = abs( pr - qr ), sr = abs( pr + qr );

  vector<L> ret;
  if( d > sr ) {
    P cp = ( pc * qr + qc *pr ) / sr;
    vector<P> pts = tangent(p,cp), qts = tangent(q,cp);
    ret.push_back( L(pts[0],qts[0]) );
    ret.push_back( L(pts[1],qts[1]) );
  } else if( abs( d - sr ) < EPS ) {
    P cp = p.c + (q.c-p.c)*(abs(q.c-p.c)/2.0);
    P vp = (q.c-p.c); vp = P( vp.imag(), -vp.real() );    
    ret.push_back( L(cp, cp+vp) );
    return ret;
  }

  if( d > dr ) {
    if( abs( pr - qr ) < EPS ) {
      P v = (qc - pc) / d;
      v *= P(0,1);
      ret.push_back( L(pc + v, qc + v) );
      ret.push_back( L(pc - v, qc - v) );
    } else {
      P cp = pc + (qc - pc) * pr / (pr - qr);
      vector<P> pts = tangent( p, cp ), qts = tangent( q, cp );
      ret.push_back( L(pts[0], qts[0]) );
      ret.push_back( L(pts[1], qts[1]) );
    }
  } else if ( abs(d - dr) < EPS ) {
    P cp = (qc - pc) * pr / (pr - qr);
    ret.push_back( L(cp,cp) );
  }
  return ret;
}


P crossPoint( L l, L m ){
  double A = cross( l.second - l.first, m.second - m.first );
  double B = cross( l.second - l.first, l.second - m.first );
  if( abs( A ) < EPS && abs( B ) < EPS ) return m.first;
  else if( abs( A ) >= EPS ) return m.first + B / A * (m.second - m.first);
}

bool isInCircle( Circle c, P p ){
  if( abs(c.c-p) < c.r - EPS ) return true;
  return false;
}

bool isCheck( L &s, vector<P> &ps, double h ){
  //cout << s.first <<" "<<s.second << endl;
  for( P &p : ps ){   
    Circle c = Circle( p, h );
    //cout << c.c << " : " << abs(c.c-proj( c.c, s )) << endl;
    if( getIntersectCS( c, s ).size() > 1 ){
      return false;      
    }
    if( isInCircle( c, s.first ) || isInCircle( c, s.second ) ) return false;
    
  }
  return true;
}

struct uni {
  int d[511];
  uni(){
    memset( d,-1,sizeof( d ) );
  }
  int find(int a){ return d[a]<0?a:(d[a]=find(d[a])); }
  bool merge(int a,int b){
    a = find(a); b = find(b);
    if( a == b ) return false;
    if( d[a] > d[b] ) swap(a,b);
    d[a] += d[b]; d[b] = a;
    return true;
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }  
};

int W,H;
int N;
int main(){
  
  cin >> W >> H >> N;
  vector<P> p(N);
  for(int i=0;i<N;i++){
    int x,y;
    cin >> x >> y; p[i] = P(x,y);
  }

  double st = 0.0, ed = 1e9;
  for(int ttt=0;ttt<50;ttt++){
    double h = (st+ed)/2.0;
    uni U;
    for(int i=0;i<N;i++){
      if( p[i].real() < h - EPS )
        U.merge( i, N );
      if( abs(W-p[i].real()) < h-EPS )
        U.merge( i, N+1 );
    }
    
    vector<L> sk;
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if( i==j ) continue;
        if( abs( p[i] - p[j] ) < 2.0 * h - EPS )
          U.merge( i,j );
      }
    }
    if( U.same( N,N+1 ) )
      ed = h;        
    else
      st = h;      
  }
  printf("%.3lf\n",ed);
  
}
accuracy: 1
time_ms: 180
memory_kb: 3292
final_rank: 8

code_snippet: //#define txtout
//#define debug
#include<bits/stdc++.h>
#define mt(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
const double pi=acos(-1.0);
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int M=1e3+10;
class UnionFindSet { ///并?集
    static const int MV=1e3+10; ///点的个数
    int par[MV],num[MV];
    void add(int son,int fa) {
        par[fa]+=par[son];
        par[son]=fa;
        num[fa]+=num[son];
    } public:
    void init(int n) {
        for(int i=0; i<=n; i++) {
            num[i]=1;
            par[i]=-1;
        }
    }
    int getroot(int x) {
        int i=x,j=x,temp;
        while(par[i]>=0) i=par[i];
        while(j!=i) {
            temp=par[j];
            par[j]=i;
            j=temp;
        }
        return i;
    } bool unite(int x,int y) {

        #ifdef debug
        printf("add x=%d  y=%d\n",x,y);
        #endif // debug

        int p=getroot(x);
        int q=getroot(y);
        if(p==q) return false;
        if(par[p]>par[q]) {
            add(p,q);
        } else {
            add(q,p);
        }
        return true;
    }
    int getnum(int id) { ///返回?点所在集合包含的点数
        return num[getroot(id)];
    }
} gx;
double W,H;
int n;
struct point {
    double x,y;
} p[M];
double Square(double x) {
    return x*x;
}
double Distance(point a,point b) {
    return sqrt(Square(a.x-b.x)+Square(a.y-b.y));
}

double xmult(point p1,point p2,point p0){
return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
double disptoline(point p,point l1,point l2){
return fabs(xmult(p,l1,l2))/Distance(l1,l2);
}

//判?段和?相交,包括端点和相切
int intersect_seg_circle(point c,double r,point l1,point l2) {
    double t1=Distance(c,l1)-r,t2=Distance(c,l2)-r;
    point t=c;
    if (t1<eps||t2<eps)
        return t1>-eps||t2>-eps;
    t.x+=l1.y-l2.y;
    t.y+=l2.x-l1.x;
    return xmult(l1,c,t)*xmult(l2,c,t)<eps&&disptoline(c,l1,l2)-r<eps;
}
bool crash(point a,point b,double r,int co){
    for(int i=0;i<n;i++){
        if(i==co) continue;
        if(intersect_seg_circle(p[i],r,a,b)) return true;
        if(Distance(a,p[i])<r&&Distance(b,p[i])<r) return true;
    }
    return false;
}
bool judge(double r) {
    int s=n;
    int t=n+1;
    gx.init(t);
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            if(Distance(p[i],p[j])>=2*r) {
                gx.unite(i,j);
            }
        }
    }
    for(int i=0; i<n; i++) {
        point p1,p2;
        p1=p[i];
        p1.x-=r;
        if(p1.x>=0){
            p2.x=p1.x;
            p2.y=0;
            if(!crash(p1,p2,r,i)){
                gx.unite(s,i);
            }
            p2.x=p1.x;
            p2.y=H;
            if(!crash(p1,p2,r,i)){
                gx.unite(t,i);
            }
        }
        p1=p[i];
        p1.x+=r;
        if(p1.x<=W){
            p2.x=p1.x;
            p2.y=0;
            if(!crash(p1,p2,r,i)){
                gx.unite(s,i);
            }
            p2.x=p1.x;
            p2.y=H;
            if(!crash(p1,p2,r,i)){
                gx.unite(t,i);
            }
        }
    }
    return gx.getroot(s)==gx.getroot(t);
}
double solve() {
    if(n==1){
        return max(p[0].x,W-p[0].x);
    }
    int step=100;
    double L=0,R=inf,result=0;
    while(step--) {
        double mid=(L+R)*0.5;
        #ifdef debug
        printf("judge mid=%.3f\n",mid);
        #endif // debug
        if(judge(mid)) {
            result=mid;
            L=mid;
        } else {
            R=mid;
        }
    }
    return result;
}
int main() {
#ifdef txtout
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif // txtout
    while(~scanf("%lf%lf%d",&W,&H,&n)) {
        for(int i=0; i<n; i++) {
            scanf("%lf%lf",&p[i].x,&p[i].y);
        }
        printf("%.3f\n",solve());
    }
    return 0;
}
accuracy: 0.11320754716981132
time_ms: 250
memory_kb: 1264
final_rank: 19

code_snippet: #include <bits/stdc++.h>
using namespace std;
const int N = 510;
const double eps = 1e-4;
int w, h, n;
struct Point
{
	double x, y;
	void in(){scanf("%lf%lf", &x, &y);}
}p[N];
inline int sgn(double x){return x < -eps ? -1 : x > eps ? 1 : 0;}
struct edge{int next, to;} e[N*N];
int head[N], tot;
void gInit(){memset(head, -1, sizeof(head)); tot = 0;}
void add_edge(int u,int v){e[tot] = (edge){head[u], v}; head[u] = tot++;}
bool vis[N];
double dist(const Point &a, const Point &b)
{
	return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
bool solve(double x)
{
	gInit();
	for(int i = 1; i <= n; ++i)
		if(sgn(p[i].x - x) < 0)
			add_edge(0, i);
	for(int i = 1; i <= n; ++i)
		for(int j = i + 1; j <= n; ++j)
			if(sgn(dist(p[i], p[j]) - x - x) < 0)
			{
				add_edge(i, j);
				add_edge(j, i);
			}
	for(int i = 1; i <= n; ++i)
		if(sgn(w - p[i].x - x) < 0)
			add_edge(i, n + 1);
	queue<int> que;
	que.push(0);
	memset(vis, false, sizeof(vis));
	vis[0] = true;
	while(!que.empty())
	{
		int u = que.front(); que.pop();
		for(int i = head[u]; ~i; i = e[i].next)
			if(!vis[e[i].to])
			{
				vis[e[i].to] = true;
				que.push(e[i].to);
			}
	}
	if(vis[n + 1]) return false;
	//check start point and end point
/*	Point w0 = (Point){w, 0};
	Point wh = (Point){w, h};
	for(int i = 1; i <= n; ++i)
	{
		if(!vis[i]) continue;
		if(sgn(dist(w0, p[i]) - x) <= 0) return false;
		if(sgn(dist(wh, p[i]) - x) <= 0) return false;
	}
*/
	return true;
}
int main()
{
	scanf("%d%d%d", &w, &h, &n);
	for(int i = 1; i <= n; ++i) p[i].in();
	double l = 0, r = 1e10, mid, ans = 0.0;
	for(int i = 0; i < 100; ++i)
	{
		mid = 0.5 * (l + r);
		if(solve(mid))
		{
			ans = mid;
			l = mid;
		}
		else
		{
			r = mid;
		}
	}
	printf("%.3f", ans);
	return 0;
}
accuracy: 1
time_ms: 120
memory_kb: 3220
final_rank: 7

code_snippet: #include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define MAXN 510
#define MAXM 1000010
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
typedef long long LL;

int w,h,n,f[MAXN];
int x[MAXN],y[MAXN];

int Find(int u)
{
    return (f[u]&&f[u]!=u)?f[u]=Find(f[u]):u;
}

void Init()
{
    scanf("%d%d%d",&w,&h,&n);
    for(int i=1;i<=n;++i)
        scanf("%d%d",x+i,y+i);
}

void Work()
{
    int i,j;
    double l,r,mid;
    for(l=0,r=1e9;r-l>1e-6;){
        memset(f,0,sizeof(f));
        mid=(l+r)/2;
        for(i=1;i<=n;++i){
            if(x[i]-mid<1e-8) f[Find(i)]=n+1;
            if(x[i]+mid-w>-(1e-8)) f[Find(i)]=n+2;
        }
        for(i=1;i<=n;++i)
            for(j=i+1;j<=n;++j){
                if(mid*2-hypot(x[i]-x[j],y[i]-y[j])>-(1e-8)) f[Find(j)]=Find(i);
            }
        if(Find(n+1)==Find(n+2)) r=mid;
        else l=mid;
    }
    printf("%.3f\n",r);
}

int main()
{
    Init();
    Work();
    return 0;
}
accuracy: 1
time_ms: 90
memory_kb: 2808
final_rank: 3