#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class TheChroniclesOfAmber { public:
double minimumTime(vector <int> princeX, vector <int> princeY, vector <int> destinationX, vector <int> destinationY)
{
int N = princeX.size();
// d[s][g] := the distance from prince[s] to dest[g]
vector< vector<double> > d(N, vector<double>(N));
for(int s=0; s<N; ++s)
for(int g=0; g<N; ++g)
d[s][g] = hypot(princeX[s]-destinationX[g], princeY[s]-destinationY[g]);
// no teleportation
double noTelepo = 0;
for(int i=0; i<N; ++i)
noTelepo = max(noTelepo, d[i][i]);
// with teleportation: at least one position must be empty
double answer = noTelepo;
for(int unused_s=0; unused_s<N; ++unused_s) {
double withTelepo = 0;
for(int g=0; g<N; ++g) { // for each goal
double t = 1e+300;
for(int s=0; s<N; ++s) if( s != unused_s )
t = min(t, d[s][g]); // find the nearest starting point
withTelepo = max(withTelepo, t);
}
answer = min(answer, withTelepo); // take the minimum
}
return answer;
}
};
// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
{ ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
{ os << "{ ";
for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const double& Expected, const double& Received) {
bool ok = (abs(Expected - Received) < 1e-9);
if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl;
cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END verify_case(_, TheChroniclesOfAmber().minimumTime(princeX, princeY, destinationX, destinationY));}
int main(){
CASE(0)
int princeX_[] = {1,5,5};
vector <int> princeX(princeX_, princeX_+sizeof(princeX_)/sizeof(*princeX_));
int princeY_[] = {0,0,0};
vector <int> princeY(princeY_, princeY_+sizeof(princeY_)/sizeof(*princeY_));
int destinationX_[] = {1,1,0};
vector <int> destinationX(destinationX_, destinationX_+sizeof(destinationX_)/sizeof(*destinationX_));
int destinationY_[] = {4,2,3};
vector <int> destinationY(destinationY_, destinationY_+sizeof(destinationY_)/sizeof(*destinationY_));
double _ = 4.0;
END
CASE(1)
int princeX_[] = {0,0,0};
vector <int> princeX(princeX_, princeX_+sizeof(princeX_)/sizeof(*princeX_));
int princeY_[] = {1,2,3};
vector <int> princeY(princeY_, princeY_+sizeof(princeY_)/sizeof(*princeY_));
int destinationX_[] = {0,0,0};
vector <int> destinationX(destinationX_, destinationX_+sizeof(destinationX_)/sizeof(*destinationX_));
int destinationY_[] = {0,2,4};
vector <int> destinationY(destinationY_, destinationY_+sizeof(destinationY_)/sizeof(*destinationY_));
double _ = 1.0;
END
CASE(2)
int princeX_[] = {0,0,0};
vector <int> princeX(princeX_, princeX_+sizeof(princeX_)/sizeof(*princeX_));
int princeY_[] = {1,2,3};
vector <int> princeY(princeY_, princeY_+sizeof(princeY_)/sizeof(*princeY_));
int destinationX_[] = {0,0,0};
vector <int> destinationX(destinationX_, destinationX_+sizeof(destinationX_)/sizeof(*destinationX_));
int destinationY_[] = {4,2,0};
vector <int> destinationY(destinationY_, destinationY_+sizeof(destinationY_)/sizeof(*destinationY_));
double _ = 1.0;
END
CASE(3)
int princeX_[] = {0,3,5};
vector <int> princeX(princeX_, princeX_+sizeof(princeX_)/sizeof(*princeX_));
int princeY_[] = {0,4,0};
vector <int> princeY(princeY_, princeY_+sizeof(princeY_)/sizeof(*princeY_));
int destinationX_[] = {3,5,0};
vector <int> destinationX(destinationX_, destinationX_+sizeof(destinationX_)/sizeof(*destinationX_));
int destinationY_[] = {4,0,0};
vector <int> destinationY(destinationY_, destinationY_+sizeof(destinationY_)/sizeof(*destinationY_));
double _ = 4.47213595499958;
END
CASE(4)
int princeX_[] = {3629,6751,8655,5115,7809,6759,7133,1810,6102,2539,1777,242};
vector <int> princeX(princeX_, princeX_+sizeof(princeX_)/sizeof(*princeX_));
int princeY_[] = {5294,180,988,7780,1635,7904,845,7405,4800,2567,4795,2339};
vector <int> princeY(princeY_, princeY_+sizeof(princeY_)/sizeof(*princeY_));
int destinationX_[] = {8723,9275,6705,5875,7981,7666,1158,4135,17,2984,5086,3570};
vector <int> destinationX(destinationX_, destinationX_+sizeof(destinationX_)/sizeof(*destinationX_));
int destinationY_[] = {6166,53,5980,4499,412,9074,8190,847,650,9158,9116,4396};
vector <int> destinationY(destinationY_, destinationY_+sizeof(destinationY_)/sizeof(*destinationY_));
double _ = 2622.582696503582;
END
CASE(5)
int princeX_[] = {0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9};
vector <int> princeX(princeX_, princeX_+sizeof(princeX_)/sizeof(*princeX_));
int princeY_[] = {0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9};
vector <int> princeY(princeY_, princeY_+sizeof(princeY_)/sizeof(*princeY_));
int destinationX_[] = {0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9};
vector <int> destinationX(destinationX_, destinationX_+sizeof(destinationX_)/sizeof(*destinationX_));
int destinationY_[] = {0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9};
vector <int> destinationY(destinationY_, destinationY_+sizeof(destinationY_)/sizeof(*destinationY_));
double _ = 0;
END
/*
CASE(6)
int princeX_[] = ;
vector <int> princeX(princeX_, princeX_+sizeof(princeX_)/sizeof(*princeX_));
int princeY_[] = ;
vector <int> princeY(princeY_, princeY_+sizeof(princeY_)/sizeof(*princeY_));
int destinationX_[] = ;
vector <int> destinationX(destinationX_, destinationX_+sizeof(destinationX_)/sizeof(*destinationX_));
int destinationY_[] = ;
vector <int> destinationY(destinationY_, destinationY_+sizeof(destinationY_)/sizeof(*destinationY_));
double _ = ;
END
*/
}
// END CUT HERE