Problem:
Problem F: Equilateral Triangle
Problem
$N$個の頂点からなる凸多角形が与えられる。
その凸多角形の全ての頂点を含む正三角形を考えるとき、その正三角形の一辺の長さの最小値を求めよ。
Input
入力は以下の形式ですべて整数で与えられる。
$N$
$px_1$ $py_1$
$px_2$ $py_2$
$\vdots$
$px_N$ $py_N$
$1$行目には凸多角形の頂点数を表す整数$N$が与えられる。
続く$N$行には凸多角形の各頂点の情報が反時計周りの順で与えられる。
$1+i$行目には$i$番目の頂点の座標を表す$px_i$,$py_i$が空白区切りで与えられる。
Constraints
入力は以下の条件を満たす。
$3 \le N \le 10000$
$-10^9 \le px_i, py_i \le 10^9$
凸多角形の頂点のうちどの3点を選んでも、同一直線上には存在しない
Output
条件を満たす正三角形の一辺の長さの最小値を出力せよ。
ただし、$10^{-5}$ までの絶対誤差または相対誤差は許容される。
Sample Input 1
4
2 3
1 2
2 1
3 2
Sample Output 1
3.04720672
Sample Input 2
7
-96469 25422
-55204 -45592
-29140 -72981
98837 -86795
92303 63297
19059 96012
-67980 70342
Sample Output 2
310622.35426197

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll ILL=2167167167167167167;
const int INF=2100000000;
#define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> int LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> int UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,T b){if(b<a){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
bool yneos(bool a,bool upp=false){if(a){cout<<(upp?"YES\n":"Yes\n");}else{cout<<(upp?"NO\n":"No\n");}return a;}
template<class T> void vec_out(vector<T> &p,int ty=0){
    if(ty==2){cout<<'{';for(int i=0;i<(int)p.size();i++){if(i){cout<<",";}cout<<'"'<<p[i]<<'"';}cout<<"}\n";}
    else{if(ty==1){cout<<p.size()<<"\n";}for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}}
template<class T> T vec_min(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;}
template<class T> T vec_max(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;}
template<class T> T vec_sum(vector<T> &a){T ans=T(0);for(auto &x:a) ans+=x;return ans;}
int pop_count(long long a){int res=0;while(a){res+=(a&1),a>>=1;}return res;}
template<class T> T square(T a){return a * a;}

using ld = long double;
const ld pi = acos(-1);

void solve();
// POP'N ROLL MUSIC / TOMOO
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    rep(i, 0, t) solve();
}

void solve(){
    int N;
    cin >> N;
    vector<ll> X(N), Y(N);
    rep(i, 0, N) cin >> X[i] >> Y[i];
    rep(i, 0, N * 2) X.push_back(X[i]), Y.push_back(Y[i]);
    auto f = [&](ld deg) -> ld {
        ld A = -sinl(deg);
        ld B = cosl(deg);
        ld res = INF;
        rep(i, 0, N) chmin(res, A * (ld)X[i] + B * (ld)Y[i]);
        return -res;
    };
    ld ans = ILL;
    rep(i, 0, N){
        ll dx = X[i + 1] - X[i];
        ll dy = Y[i + 1] - Y[i];
        ld deg = 0;
        if (dx == 0){
            if (dy > 0) deg = pi / 2;
            else deg = pi + pi / 2;
        }
        else if (dy == 0){
            if (dx > 0) deg = 0;
            else deg = pi;
        }
        else{
            deg = atan((ld)(dy) / (ld)(dx));
            if (dx < 0) deg += pi;
        }
        ld sum = 0;
        rep(j, 0, 3){
            sum += f(deg + (pi * 2 * j) / 3);
        }
        chmin(ans, sum);
    }
    ans /= sqrtl(3);
    ans *= 2;
    cout << fixed << setprecision(20) << ans << "\n";
}
accuracy: 1
time_ms: 670
memory_kb: 4196
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll ILL=2167167167167167167;
const int INF=2100000000;
#define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> int LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> int UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,T b){if(b<a){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
bool yneos(bool a,bool upp=false){if(a){cout<<(upp?"YES\n":"Yes\n");}else{cout<<(upp?"NO\n":"No\n");}return a;}
template<class T> void vec_out(vector<T> &p,int ty=0){
    if(ty==2){cout<<'{';for(int i=0;i<(int)p.size();i++){if(i){cout<<",";}cout<<'"'<<p[i]<<'"';}cout<<"}\n";}
    else{if(ty==1){cout<<p.size()<<"\n";}for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}}
template<class T> T vec_min(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;}
template<class T> T vec_max(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;}
template<class T> T vec_sum(vector<T> &a){T ans=T(0);for(auto &x:a) ans+=x;return ans;}
int pop_count(long long a){int res=0;while(a){res+=(a&1),a>>=1;}return res;}
template<class T> T square(T a){return a * a;}

using ld = long double;
const ld pi = acos(-1);

void solve();
// POP'N ROLL MUSIC / TOMOO
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    rep(i, 0, t) solve();
}

void solve(){
    int N;
    cin >> N;
    vector<ll> X(N), Y(N);
    rep(i, 0, N) cin >> X[i] >> Y[i];
    rep(i, 0, N * 2) X.push_back(X[i]), Y.push_back(Y[i]);
    auto f = [&](ld deg) -> ld {
        ld A = sinl(deg);
        ld B = cosl(deg);
        ld res = INF;
        rep(i, 0, N) chmin(res, A * X[i] + B * Y[i]);
        return -res;
    };
    ld ans = INF;
    rep(i, 0, N){
        ll dx = X[i + 1] - X[i];
        ll dy = Y[i + 1] - Y[i];
        ld deg = 0;
        if (dx == 0){
            if (dy > 0) deg = pi / 2;
            else deg = pi + pi / 2;
        }
        else if (dy == 0){
            if (dx > 0) deg = 0;
            else deg = pi;
        }
        else{
            deg = atan((ld)(dy) / (ld)(dx));
            if (dx < 0) deg = pi - deg;
            else if (dy < 0) deg += pi * 2;
        }
        ld sum = 0;
        rep(j, 0, 3){
            sum += f(deg + (pi * 2 * j) / 3);
        }
        chmin(ans, sum);
    }
    ans /= sqrtl(3);
    ans *= 2;
    cout << fixed << setprecision(20) << ans << "\n";
}
// わかっていない
accuracy: 0.375
time_ms: 650
memory_kb: 4212
final_rank: 17

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001




#define SIZE 10005

struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{

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

			return x < p.x;
		}else{

			return y < p.y;
		}
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}


	void debug(){

		printf("(%.3lf,%.3lf)\n",x,y);
	}

	double x,y;
};

typedef Point Vector;
typedef vector<Point> Polygon;

struct Line{
	Line(){

	}
	Line(Point a,Point b){
		p[0] = a;
		p[1] = b;
	}
	/*void outPut(){

		printf("(%.3lf,%.3lf)-(%.3lf,%.3lf)\n",p[0].x,p[0].y,p[1].x,p[1].y);
	}*/
	Point p[2];
};

Point point[SIZE];


double norm(Vector a){
	return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
	return sqrt(norm(a));
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

/*
 * p0を基準点として、p1から見てp2が
 * 反時計回り側にあれば
 * COUNTER_CLOCKWISE
 * */
int ccw(Point p0,Point p1,Point p2){

	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
	if(cross(a,b) < -EPS)return CLOCKWISE;
	if(dot(a,b) < -EPS)return ONLINE_BACK;
	if(a.norm() < b.norm())return ONLINE_FRONT;

	return ON_SEGMENT;
}

//点のradを求める関数
double calc_rad(Point p){

	if(p.y == 0){

		if(p.x > 0){

			return 0;

		}else{ //p.x < 0

			return M_PI;
		}

	}else if(p.x == 0){

		if(p.y > 0){

			return M_PI/2.0;
		}else{


			return 3*M_PI/2.0;
		}

	}else{

		double base = atan(fabs(p.y)/fabs(p.x));

		if(p.x > 0){

			if(p.y > 0){

				return base;

			}else{ //p.y < 0

				return 2*M_PI-base;
			}

		}else{ //p.x < 0

			if(p.y > 0){

				return M_PI-base;

			}else{

				return base+M_PI;
			}
		}
	}
}

/*点moveをbaseを中心にradラジアン回転させる
rad > 0なら反時計回り、rad < 0なら時計周り
*/
Point rotate(Point base,Point move,double rad){

	Point ret;
	//move = move-base;

	ret.x = move.x*cos(rad)-move.y*sin(rad);
	ret.y = move.x*sin(rad)+move.y*cos(rad);

	//ret = ret+base;

	return ret;
}


int main(){

	int N;
	scanf("%d",&N);


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


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

	double ans = HUGE_NUM;

	Point center = Point(0,0);

	double num = sqrt(3);

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

		Point base = point[i];
		int k = (i+1)%N;

		double rad = calc_rad(point[k]-base);

		double L = 0,R = 0;

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

			Point tmp_p = point[a]-base;
			tmp_p = rotate(center,tmp_p,-rad);

			//左下方向60度の直線とx軸の交点
			double tmp_L = (num*tmp_p.x-tmp_p.y)/num;
			L = min(L,tmp_L);

			//右下方向60度の直線とx軸の交点
			double tmp_R = (num*tmp_p.x+tmp_p.y)/num;
			R = max(R,tmp_R);
		}

		ans = min(ans,R-L);
	}

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

	return 0;
}
accuracy: 1
time_ms: 2860
memory_kb: 3908
final_rank: 16

code_snippet: #include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)

struct P{
    double X;
    double Y;
    P(double x=0.0, double y=0.0): X(x),Y(y){}

    inline const P inv() const { return P(X/(X*X+Y*Y), -Y/(X*X+Y*Y)); }
    inline const P operator -() const { return P(-X, -Y); }
    inline const P operator +(const P& a) const { return P(X+a.X, Y+a.Y); }
    inline const P operator -(const P& a) const { return P(X-a.X, Y-a.Y); }
    inline const P operator *(const P& a) const { return P(X*a.X -Y*a.Y, X*a.Y +Y*a.X); }
    inline const P operator /(const P& a) const { return *this *a.inv(); }
    inline const P operator *(const double& c) const { return P(c*X, c*Y); }
    inline const P operator /(const double& c) const { return P(X/c, Y/c); }

    inline P& operator +=(const P& a){ X+=a.X; Y+=a.Y; return *this; }
    inline P& operator -=(const P& a){ X-=a.X; Y-=a.Y; return *this; }
    inline P& operator *=(const P& a){ double nX=X*a.X-Y*a.Y; Y=X*a.Y+Y*a.X; X=nX; return *this; }
    inline P& operator /=(const P& a){ double d=a.X*a.X+a.Y*a.Y; double nX=(X*a.X+Y*a.Y)/d; Y=(-X*a.Y+Y*a.X)/d; X=nX; return *this; }
    inline P& operator *=(const double& c){ X*=c; Y*=c; return *this; }
    inline P& operator /=(const double& c){ X/=c; Y/=c; return *this; }

    inline bool operator ==(const P& a) const { return EQ(X,a.X) and EQ(Y,a.Y); }
    inline bool operator !=(const P& a) const { return !(*this==a); }
    inline bool operator <(const P& a) const { return !EQ(X,a.X)? X<a.X: Y+EPS<a.Y; }
    inline bool operator <=(const P& a) const { return *this<a or *this==a; }
    inline bool operator >(const P& a) const { return !(*this<=a); }
    inline bool operator >=(const P& a) const { return !(*this<a); }
};
P operator *(const double& c, const P& p){ return P(c*p.X, c*p.Y); }
double norm(const P& a){ return a.X*a.X +a.Y*a.Y; }
double abs(const P& a){ return sqrt(a.X*a.X +a.Y*a.Y); }
double arg(const P& a){ return atan2(a.X, a.Y); }
double dot(const P& a, const P& b){ return a.X*b.X +a.Y*b.Y; }
double cross(const P& a, const P& b){ return a.X*b.Y -a.Y*b.X; }
std::ostream& operator <<(std::ostream& lhs, const P& rhs){
    lhs << "(" << rhs.X << ", " << rhs.Y << ")";
    return lhs;
}

typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

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(dot(b,c-b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}
P unit(const P &p){
    return p/abs(p);
}
P rotate(const P &p, double rad){
    return p *P(cos(rad), sin(rad));
}

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]);
}

int main(){
    int n;
    cin >> n;
    VP p(n);
    for(int i=0; i<n; i++){
        cin >> p[i].X >> p[i].Y;
    }
    double ans = INF;
    for(int i=0; i<n; i++){
        L edge(p[i], p[(i+1)%n]);
        P lmin = edge[0];
        P lmax = edge[0];
        P ldir = rotate(edge[1]-edge[0], PI/3.0);
        for(int j=0; j<n; j++){
            P cp = crosspointLL(edge, L(p[j], p[j]+ldir));
            lmin = min(lmin, cp);
            lmax = max(lmax, cp);
        }
        P rmin = edge[0];
        P rmax = edge[0];
        P rdir = rotate(edge[1]-edge[0], PI*2.0/3.0);
        for(int j=0; j<n; j++){
            P cp = crosspointLL(edge, L(p[j], p[j]+rdir));
            rmin = min(rmin, cp);
            rmax = max(rmax, cp);
        }
        ans = min(ans, max(abs(lmin-rmax), abs(lmax-rmin)));
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 1980
memory_kb: 3516
final_rank: 13

code_snippet: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}



#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define PI 3.141592653589793238
 
// COUNTER CLOCKWISE
static const Int CCW_COUNTER_CLOCKWISE = 1;
static const Int CCW_CLOCKWISE = -1;
static const Int CCW_ONLINE_BACK = 2;
static const Int CCW_ONLINE_FRONT = -2;
static const Int CCW_ON_SEGMENT = 0;

struct Point{
  double x,y;
  Point(){}
  Point(double x,double y) :x(x),y(y){}
  Point operator+(Point p) {return Point(x+p.x,y+p.y);}
  Point operator-(Point p) {return Point(x-p.x,y-p.y);}
  Point operator*(double k){return Point(x*k,y*k);}
  Point operator/(double k){return Point(x/k,y/k);}
  double norm(){return x*x+y*y;}
  double abs(){return sqrt(norm());}

  bool operator < (const Point &p) const{
    return x!=p.x?x<p.x:y<p.y;
    //grid-point only
    //return !equals(x,p.x)?x<p.x:!equals(y,p.y)?y<p.y:0;
  }

  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
  }
};

struct EndPoint{
  Point p;
  Int seg,st;
  EndPoint(){}
  EndPoint(Point p,Int seg,Int st):p(p),seg(seg),st(st){}
  bool operator<(const EndPoint &ep)const{
    if(p.y==ep.p.y) return st<ep.st;
    return p.y<ep.p.y;
  }
};

istream &operator >> (istream &is,Point &p){
  is>>p.x>>p.y;
  return is;
}

ostream &operator << (ostream &os,Point p){
  os<<fixed<<setprecision(12)<<p.x<<" "<<p.y;
  return os;
}

bool sort_x(Point a,Point b){
  return a.x!=b.x?a.x<b.x:a.y<b.y;
}

bool sort_y(Point a,Point b){
  return a.y!=b.y?a.y<b.y:a.x<b.x;
}

typedef Point Vector;
typedef vector<Point> Polygon;

istream &operator >> (istream &is,Polygon &p){
  for(Int i=0;i<(Int)p.size();i++) is>>p[i];
  return is;
}

struct Segment{
  Point p1,p2;
  Segment(){}
  Segment(Point p1, Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

istream &operator >> (istream &is,Segment &s){
  is>>s.p1>>s.p2;
  return is;
}

double norm(Vector a){
  return a.x*a.x+a.y*a.y;
}
double abs(Vector a){
  return sqrt(norm(a));
}
double dot(Vector a,Vector b){
  return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}

Point orth(Point p){return Point(-p.y,p.x);}

Point project(Segment s,Point p){
  Vector base=s.p2-s.p1;
  double r=dot(p-s.p1,base)/norm(base);
  return s.p1+base*r;
}

Point reflect(Segment s,Point p){
  return p+(project(s,p)-p)*2.0;
}

double arg(Vector p){
  return atan2(p.y,p.x);
}

Vector polar(double a,double r){
  return Point(cos(r)*a,sin(r)*a);
}

Int ccw(Point p0,Point p1,Point p2){
  Vector a = p1-p0;
  Vector b = p2-p0;
  if(cross(a,b) > EPS) return CCW_COUNTER_CLOCKWISE;
  if(cross(a,b) < -EPS) return CCW_CLOCKWISE;
  if(dot(a,b) < -EPS) return CCW_ONLINE_BACK;
  if(a.norm()<b.norm()) return CCW_ONLINE_FRONT;
  return CCW_ON_SEGMENT;
}

bool intersectSS(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4) <= 0 &&
          ccw(p3,p4,p1)*ccw(p3,p4,p2) <= 0 );
}

bool intersectSS(Segment s1,Segment s2){
  return intersectSS(s1.p1,s1.p2,s2.p1,s2.p2);
}

bool intersectPS(Polygon p,Segment l){
  Int n=p.size();
  for(Int i=0;i<n;i++)
    if(intersectSS(Segment(p[i],p[(i+1)%n]),l)) return 1;
  return 0;
}

double getDistanceLP(Line l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

double getDistanceSP(Segment s,Point p){
  if(dot(s.p2-s.p1,p-s.p1) < 0.0 ) return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2) < 0.0 ) return abs(p-s.p2);
  return getDistanceLP(s,p);
}

double getDistanceSS(Segment s1,Segment s2){
  if(intersectSS(s1,s2)) return 0.0;
  return min(min(getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2)),
             min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}

Point getCrossPointSS(Segment s1,Segment s2){
  for(Int k=0;k<2;k++){
    if(getDistanceSP(s1,s2.p1)<EPS) return s2.p1; 
    if(getDistanceSP(s1,s2.p2)<EPS) return s2.p2;
    swap(s1,s2);
  }
  Vector base=s2.p2-s2.p1;
  double d1=abs(cross(base,s1.p1-s2.p1));
  double d2=abs(cross(base,s1.p2-s2.p1));
  double t=d1/(d1+d2);
  return s1.p1+(s1.p2-s1.p1)*t;
}

Point getCrossPointLL(Line l1,Line l2){
  double a=cross(l1.p2-l1.p1,l2.p2-l2.p1);
  double b=cross(l1.p2-l1.p1,l1.p2-l2.p1);
  if(abs(a)<EPS&&abs(b)<EPS) return l2.p1;
  return l2.p1+(l2.p2-l2.p1)*(b/a);
}

// IN:2 ON:1 OUT:0
Int contains(Polygon g,Point p){
  Int n=g.size();
  bool x=false;
  for(Int i=0;i<n;i++){
    Point a=g[i]-p,b=g[(i+1)%n]-p;
    if(fabs(cross(a,b)) < EPS && dot(a,b) < EPS) return 1;
    if(a.y>b.y) swap(a,b);
    if(a.y < EPS && EPS < b.y && cross(a,b) > EPS ) x = !x;
  }
  return (x?2:0);
}

Vector translate(Vector v,double theta){
  Vector res;
  res.x=cos(theta)*v.x-sin(theta)*v.y;
  res.y=sin(theta)*v.x+cos(theta)*v.y;
  return res;
}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  Polygon ps(n);
  for(Int i=0;i<n;i++) cin>>ps[i];
  for(Int i=0;i<n;i++) ps.push_back(Point(ps[i]));
  for(Int i=0;i<n;i++) ps.push_back(Point(ps[i]));

  double ans=1e18;
  Int l=n,r=n+1;
  for(Int i=n;i<n+n;i++){
    while(r<i+1) r++;
    double th=arg(ps[i+1]-ps[i]);
    Vector v1=polar(100,th+2*PI/3);
    Vector v2=polar(100,th+4*PI/3);

    Line b(ps[i],ps[i+1]);

    auto calc=
      [&](Int k,Vector v,Int w)->double{
        Point p=getCrossPointLL(b,Line(ps[k],ps[k]+v));
        if(abs(p-ps[i+w])<abs(p-ps[i+!w])) return -1;
        return abs(p-ps[i+w]);        
      };
    
    while(calc(l,v2,1)<0) l++;
    while(calc(l,v2,1)<calc(l-1,v2,1)) l--;
    while(calc(l,v2,1)<calc(l+1,v2,1)) l++;
    while(calc(r,v1,0)<calc(r-1,v1,0)) r--;
    while(calc(r,v1,0)<calc(r+1,v1,0)) r++;

    Point p1=getCrossPointLL(b,Line(ps[r],ps[r]+v1));
    Point p2=getCrossPointLL(b,Line(ps[l],ps[l]+v2));
    chmin(ans,abs(p1-p2));
  }

  cout<<ans<<endl;
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3728
final_rank: 7

code_snippet: /*  -*- coding: utf-8 -*-
 *
 * 3056.cc: Equilateral Triangle
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 10000;
const double PI = acos(-1.0);
const double TH60 = PI * 2 * 60 / 360;
const double C60 = cos(TH60), S60 = sin(TH60);
const double DINF = 1e60;

/* typedef */

template <typename T>
struct Pt {
  T x, y;

  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt<T> &pt) : x(pt.x), y(pt.y) {}

  Pt<T> operator+(const Pt<T> pt) const { return Pt<T>(x + pt.x, y + pt.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt<T> pt) const { return Pt<T>(x - pt.x, y - pt.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt<T> v) const { return x * v.x + y * v.y; }
  T cross(Pt<T> v) const { return x * v.y - y * v.x; }
  T d2() { return x * x + y * y; }
  double d() { return sqrt(d2()); }

  Pt<T> rot60() { return Pt<T>(C60 * x - S60 * y, S60 * x + C60 * y); }
  Pt<T> rot300() { return Pt<T>(C60 * x + S60 * y, -S60 * x + C60 * y); }

  Pt<T> normalize() {
    double d0 = d();
    return (d0 != 0.0) ? Pt<T>(x / d0, y / d0) : *this;
  }

  bool operator==(const Pt<T> pt) const { return x == pt.x && y == pt.y; }
  bool operator<(const Pt<T> &pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }

  bool read() { return (scanf("%lf%lf", &x, &y) == 2); }
  void print() { printf("(%lf,%lf)", x, y); }
};

typedef Pt<double> pt;

struct CL {
  pt p;
  double t0, t1;
  CL() {}
  CL(const pt& _p, double _t0, double _t1) : p(_p), t0(_t0), t1(_t1) {}
};

/* global variables */

pt ps[MAX_N];

/* subroutines */

bool cross_lines(const pt& ap, const pt av, const pt& bp, const pt bv,
		 CL& cl) {
  double op01 = av.cross(bv);
  //if (op01 == 0.0) return false; /* need to handle parallel?? */

  if (op01 == 0.0) {
    pt v = bp - ap;
    if (v.cross(av) != 0.0) return false;

    pt a1 = ap + av;
    pt b1 = bp + bv;

    return
      ((bp - ap).dot(b1 - ap) <= 0.0 ||
       (bp - a1).dot(b1 - a1) <= 0.0 ||
       (ap - bp).dot(a1 - bp) <= 0.0 ||
       (ap - b1).dot(a1 - b1) <= 0.0);
  }

  pt v = bp - ap;
  double op0 = v.cross(av);
  double op1 = v.cross(bv);

  double t0 = op1 / op01;
  double t1 = op0 / op01;

  cl.p = bv * t1 + bp;
  cl.t0 = t0;
  cl.t1 = t1;

  return true;
  //return (0.0 <= cl.t0 && cl.t0 <= 1.0 && 0.0 <= cl.t1 && cl.t1 <= 1.0);
}

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) ps[i].read();

  double minl = DINF;
  for (int i = 0; i < n; i++) {
    pt &p0 = ps[i], &p1 = ps[(i + 1) % n];
    pt v0 = (p1 - p0).normalize();
    pt v1 = v0.rot60(), v2 = v0.rot300();
    double mint = 0.0, maxt = 0.0;

    for (int j = 0; j < n; j++) {
      CL cl1, cl2;
      cross_lines(p0, v0, ps[j], v1, cl1);
      cross_lines(p0, v0, ps[j], v2, cl2);
      if (mint > cl1.t0) mint = cl1.t0;
      if (maxt < cl2.t0) maxt = cl2.t0;
    }
    double l = maxt - mint;
    if (minl > l) minl = l;
  }

  printf("%.8lf\n", minl);
  return 0;
}
accuracy: 1
time_ms: 1380
memory_kb: 3364
final_rank: 10

code_snippet: #include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <numeric>
#include <climits>
#include <cfloat>

struct Point;
struct Vector;
struct Angle;
class Line;
struct Point {
	long double x, y;
	long double distance(const Point& that) const;
	Vector operator-(const Point& that) const;
};
struct Vector {
	long double x, y;
	Angle angle_from(const Vector& that) const;
	Angle angle() const;
	long double length() const;
	long double cross(const Vector& that) const;
	long double dot(const Vector& that) const;
};
struct Angle {
	static const long double Pi;
	static const Angle degree0;
	static const Angle degree120;
	static const Angle degree240;
	long double sin, cos;
	Angle operator+(const Angle& that) const;
	Angle operator-(const Angle& that) const;
	long double radian() const;
	bool near_enough(const Angle& that) const;
};
const Angle Angle::degree0 = Angle{ 0, 1 };
const Angle Angle::degree120 = Angle{ std::sqrt(3.0) / 2, -1.0 / 2 };
const Angle Angle::degree240 = Angle{ -std::sqrt(3.0) / 2, -1.0 / 2 };
struct AngleRange {
	Angle from, to;
	bool contains(const Angle& that) const;
};
class Line {
	long double a, b, c;
public:
	Line(const Point& point, const Angle& angle) :a{ angle.sin }, b{ -angle.cos }, c{ -point.x * angle.sin + point.y * angle.cos }{}
	Line(const Point& point, const Vector& vec) :Line(point, vec.angle()) {}
	Point cross_point(const Line& that) const;
};
template<typename T>
class RingArray {
	std::vector<T> array;
public:
	RingArray() {};
	RingArray(const int size) : array(size) {};
	void push_back(const T& value);
	const T& operator[](const int index) const;
	T& operator[](const int index);
};

long double Point::distance(const Point& that) const
{
	return (*this - that).length();
}
Vector Point::operator-(const Point& that) const {
	return Vector{ x - that.x, y - that.y };
}

Angle Vector::angle_from(const Vector& that) const
{
	auto len = length() * that.length();
	auto sin = cross(that) / len;
	auto cos = dot(that) / len;
	return Angle{ sin, cos };
}

Angle Vector::angle() const
{
	auto len = length();
	return Angle{ y / len, x / len };
}

long double Vector::length() const
{
	return std::sqrt(x * x + y * y);
}

long double Vector::cross(const Vector& that) const
{
	return x * that.y - y * that.x;
}

long double Vector::dot(const Vector& that) const
{
	return x * that.x + y * that.y;
}
const long double Angle::Pi = std::acos(-1.0);
Angle Angle::operator+(const Angle& that) const
{
	return Angle{ sin * that.cos + cos * that.sin, cos * that.cos - sin * that.sin };
}

Angle Angle::operator-(const Angle& that) const
{
	return Angle{ sin * that.cos - cos * that.sin, cos * that.cos + sin * that.sin };
}

long double Angle::radian() const
{
	if (cos >= 1) return 0;
	else if (cos <= -1) return Pi;
	else if (sin >= 0) return std::acos(cos);
	else return Pi * 2 - std::acos(cos);
}

bool Angle::near_enough(const Angle& that) const
{
	return (*this - that).cos + 0.0000001 >= 1;
}

bool AngleRange::contains(const Angle& that) const
{
	return to.near_enough(that) || from.near_enough(that) || (to - from).radian() + LDBL_EPSILON >= (that - from).radian();
}

Point Line::cross_point(const Line& that) const
{
	const auto d = a * that.b - b * that.a;
	return Point{ (b * that.c - c * that.b) / d, (c * that.a - a * that.c) / d };
}

template<typename T>
void RingArray<T>::push_back(const T& value)
{
	array.push_back(value);
}

template<typename T>
const T& RingArray<T>::operator[](const int index) const
{
	return array[index % array.size()];
}

template<typename T>
T& RingArray<T>::operator[](const int index)
{
	return array[index % array.size()];
}
int main() {
	int n; std::cin >> n;
	RingArray<Point> points(n);
	for (auto i = 0; i < n; ++i) std::cin >> points[i].x >> points[i].y;
	AngleRange first_angle{ Angle::degree0, Angle::degree120 }, second_angle{ Angle::degree0, Angle::degree240 };
	std::queue<int> first_suspect, second_suspect;
	for (auto i = 1; i < n; ++i) {
		first_suspect.push(i); second_suspect.push(i);
	}
	int first{ 0 }, second{ 0 };
	long double min = LDBL_MAX;
	for (auto i = 0; i < n; ++i) {
		first_suspect.push(i); second_suspect.push(i);
		auto base = points[i + 1] - points[i];
		while (first_angle.contains(base.angle_from(points[first + 1] - points[first])) && !first_suspect.empty()) {
			first = first_suspect.front(); first_suspect.pop();
		}
		while (second_angle.contains(base.angle_from(points[second + 1] - points[second])) && !second_suspect.empty()) {
			second = second_suspect.front(); second_suspect.pop();
		}
		auto base_line = Line(points[i], base);
		auto crosspoint_first = base_line.cross_point(Line(points[first], base.angle() + Angle::degree120));
		auto crosspoint_second = base_line.cross_point(Line(points[second], base.angle() + Angle::degree240));
		auto len = crosspoint_first.distance(crosspoint_second);
		if (min > len) min = len;
	}
	std::cout << std::setprecision(10) << std::fixed << min << std::endl;
}
accuracy: 0.0625
time_ms: 10
memory_kb: 3500
final_rank: 18

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>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ld INF = (ld)10000000000;
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++)
typedef complex<ld> Point;
const ld eps = 1e-7;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;

//外心を求める。3点が同一直線上だとRE
LDP cent(LDP a[3]) {
	ld x[2], y[2];
	rep(i, 2) {
		x[i] = a[i + 1].first - a[0].first;
		y[i] = a[i + 1].second - a[0].second;
	}
	ld bunbo = 2 * (x[0] * y[1] - y[0] * x[1]);
	ld cx = (x[0] * x[0] * y[1] + y[0] * y[0] * y[1] - y[0] * x[1] * x[1] - y[0] * y[1] * y[1]) / bunbo;
	ld cy = (x[0] * x[1] * x[1] + x[0] * y[1] * y[1] - x[0] * x[0] * x[1] - y[0] * y[0] * x[1]) / bunbo;
	return { cx + a[0].first,cy + a[0].second };
}


bool eq(ld a, ld b) {
	return (abs(a - b) < eps);
}
//内積
ld dot(Point a, Point b) {
	return real(conj(a)*b);
}
//外積
ld cross(Point a, Point b) {
	return imag(conj(a)*b);
}
//線分
//直線にするなら十分通い２点を端点とすればよい
class Line {
public:
	Point a, b;
};
//円
class Circle {
public:
	Point p;
	ld r;
};
//3点の位置関係
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の順に一直線
}
//2直線の交差判定
bool isis_ll(Line l, Line m) {
	return !eq(cross(l.b - l.a, m.b - m.a), 0);
}
//直線と線分の交差判定
bool isis_ls(Line l, Line s) {
	return (cross(l.b - l.a, s.a - l.a)*cross(l.b - l.a, s.b - l.a) < eps);
}
//点が直線上に存在するか
bool isis_lp(Line l, Point p) {
	return (abs(cross(l.b - p, l.a - p)) < eps);
}
//点が線分上に存在するか
bool isis_sp(Line s, Point p) {
	return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}
//線分と線分の交差判定
bool isis_ss(Line s, Line t) {
	if (isis_sp(s, t.a) || isis_sp(s, t.b) || isis_sp(t, s.a) || isis_sp(t, s.b))return true;
	return(cross(s.b - s.a, t.a - s.a)*cross(s.b - s.a, t.b - s.a) < -eps && cross(t.b - t.a, s.a - t.a)*cross(t.b - t.a, s.b - t.a) < -eps);
}
//点から直線への垂線の足
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);
}
//直線と直線の交点
//平行な２直線に対しては使うな！！！！
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);
}
//直線と点の距離
ld dist_lp(Line l, Point p) {
	return abs(p - proj(l, p));
}
//直線と直線の距離
ld dist_ll(Line l, Line m) {
	return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}
//線分と直線の距離
ld dist_ls(Line l, Line s) {
	return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}
//線分と点の距離
ld dist_sp(Line s, Point p) {
	Point r = proj(s, p);
	return isis_sp(s, r) ? abs(p - r) : min(abs(p - s.a), abs(p - s.b));
}
//線分と線分の距離
ld dist_ss(Line s, Line t) {
	if (isis_ss(s, t))return 0;
	return min({ dist_sp(s,t.a),dist_sp(s,t.b),dist_sp(t,s.a),dist_sp(t,s.b) });
}

int n;
Point p[10001];
const ld th = pi / 3;
int main() {
	cout << fixed << setprecision(6);
	cin >> n;
	rep(i, n) {
		ld x, y; cin >> x >> y;
		p[i] = { x,y };
	}
	p[n] = p[0];
	ld out = INF;
	int l = 1, r = 1;
	rep(i, n) {
		Point d = p[i + 1] - p[i];
		Point d1 = d * Point{ cos(th),sin(th) };
		Point d2 = d * Point{ cos(-th),sin(-th) };
		Point x1 = p[i] + Point{ -INF * real(d1),-INF * imag(d1) };
		Point x2 = p[i] + Point{ INF * real(d1),INF * imag(d1) };
		Point y1 = p[i + 1] + Point{ -INF * real(d2),-INF * imag(d2) };
		Point y2 = p[i + 1] + Point{ INF*real(d2),INF*imag(d2) };
		Line l1 = { x1,x2 }, l2 = { y1,y2 };
		while (r!=i&&ccw(x1, p[r], x2) != -1) {
			r = (r + 1) % n;
		}
		while (r != i) {
			ld le = dist_lp(l1, p[r]);
			ld ri = dist_lp(l1, p[(r+1)%n]);
			if (le < ri)r = (r + 1) % n;
			else break;
		}
		ld ans = abs(p[i + 1] - p[i]);
		ans += max((ld)0,dist_lp(l1,p[r]) * 2 / sqrt(3.0));
		/*while (l != i + 1 && ccw(y1, p[l], y2) != -1) {
			l = (l - 1+n) % n;
		}*/
		if (l == i)l = (l + 1) % n;
		while (ccw(y1, p[(l + 1) % n],y2) == -1) {
			ld le = dist_lp(l2, p[l]);
			ld ri = dist_lp(l2, p[(l + 1) % n]);
			if (le < ri)l = (l + 1) % n;
			else break;
		}
		ans += max(ld(0),dist_lp(l2,p[l]) * 2 / sqrt(3.0));
		out = min(out, ans);
	}
	cout << out << endl;
	//stop
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3688
final_rank: 6

code_snippet: #include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

////////////////////////////
// 基本要素 (点, 線分)
////////////////////////////

using DD = double;
const DD INF = 1LL<<35;      // to be set appropriately
const DD EPS = 1e-6;        // to be set appropriately
const DD PI = acos(-1.0);
DD torad(int deg) {return (DD)(deg) * PI / 180;}
DD todeg(DD ang) {return ang * 180 / PI;}

/* Point */
struct Point {
    DD x, y;
    Point(DD x = 0.0, DD y = 0.0) : x(x), y(y) {}
    friend ostream& operator << (ostream &s, const Point &p) {return s << '(' << p.x << ", " << p.y << ')';}
};
inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);}
inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);}
inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);}
inline Point conj(const Point &p) {return Point(p.x, -p.y);}
inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
inline Point rot90(const Point &p) {return Point(-p.y, p.x);}
inline DD cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;}
inline DD dot(const Point &p, const Point &q) {return p.x * q.x + p.y * q.y;}
inline DD norm(const Point &p) {return dot(p, p);}
inline DD abs(const Point &p) {return sqrt(dot(p, p));}
inline DD amp(const Point &p) {DD res = atan2(p.y, p.x); if (res < 0) res += PI*2; return res;}
inline bool eq(const Point &p, const Point &q) {return abs(p - q) < EPS;}
inline bool operator < (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x < q.x : p.y < q.y);}
inline bool operator > (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x > q.x : p.y > q.y);}
inline Point operator / (const Point &p, const Point &q) {return p * conj(q) / norm(q);}


DD solve(int i, const vector<Point> &vp) {
    // vp[i] が原点に、辺 (vp[i], vp[i+1]) が x 軸上正の向きに来るように回転する
    int N = vp.size();
    Point p = vp[i];
    Point q = vp[(i+1) % N];
    DD th = atan2(q.y - p.y, q.x - p.x);
    vector<Point> nvp = vp;
    for (int i = 0; i < N; ++i) {
        nvp[i] = nvp[i] - p;
        nvp[i] = rot(nvp[i], -th);
    }

    // 各頂点から左右に 60 度の方向にビームを打つ
    DD mi = 0, ma = 0;
    for (int i = 0; i < N; ++i) {
        mi = min(mi, nvp[i].x - nvp[i].y / sqrt(3.0));
        ma = max(ma, nvp[i].x + nvp[i].y / sqrt(3.0));
    }
    return ma - mi;
}


int main() {
    int N; cin >> N;
    vector<Point> vp(N);
    for (int i = 0; i < N; ++i) cin >> vp[i].x >> vp[i].y;

    DD res = INF;
    for (int i = 0; i < N; ++i) res = min(res, solve(i, vp));
    cout << fixed << setprecision(10) << res << endl;
}
accuracy: 1
time_ms: 560
memory_kb: 3840
final_rank: 8

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
P pts[12525];
const Real PI = 4.0*atan(1.0);

Real dot(P a, P b){return real(a*conj(b));}
Real cross(P a, P b){return imag(a*conj(b));}

P getPoint(P s, P v1, P t, P v2){
  P n = v2*exp(P(0,PI/2.0));
  Real x = dot(n,t-s) / dot(n,v1);
  return s + v1*x;
}

Real f(Real th, int id){
  return cos(th)*pts[id].real() + sin(th)*pts[id].imag();
}

int main(){
  double rnd = rand() / 65536.0;
  scanf("%d",&n);
  REP(i,n){
    int x,y;
    scanf("%d%d",&x,&y);
    pts[i] = P(x,y) * exp(P(0,rnd));
  }
  vector<double> queries;
  map<double,int> qans;
  REP(i,n){
    P a = pts[i], b = pts[(i+1)%n];
    P v = b-a;
    v *= exp(P(0,-PI/2.0));
    double th = arg(v);
    queries.push_back(th);
    th += PI*2.0/3.0;
    while(th>PI)th -= 2.0*PI;
    queries.push_back(th);
    th += PI*2.0/3.0;
    while(th>PI)th -= 2.0*PI;
    queries.push_back(th);
  }
  sort(ALL(queries));
  // query
  int cur = 0;
  REP(i,n)if(pts[i].real() < pts[cur].real()){
    cur = i;
  }
  REP(i,queries.size()){
    double th = queries[i];
    while(true){
      int ni = (cur + 1) % n;
      if(f(th,cur) < f(th,ni)){
        cur = ni;
      }else{
        break;
      }
    }
    qans[th] = cur;
  }
  // calc
  double ans = 1e25;
  REP(i,n){
    P a = pts[i], b = pts[(i+1)%n];
    P v = b-a;
    v *= exp(P(0,-PI/2.0));
    double th = arg(v);
    int sid = qans[th];
    double th2 = th + PI*2.0/3.0;
    while(th2>PI)th2 -= 2.0*PI;
    int tid = qans[th2];
    double th3 = th2 + PI*2.0/3.0;
    while(th3>PI)th3 -= 2.0*PI;
    int uid = qans[th3];
    P c1 = getPoint(pts[sid], exp(P(0,th+PI/2.0)), pts[tid], exp(P(0,th2+PI/2.0)));
    P c2 = getPoint(pts[sid], exp(P(0,th+PI/2.0)), pts[uid], exp(P(0,th3+PI/2.0)));
    CHMIN(ans, abs(c1-c2));
  }
  printf("%.9f\n",ans);
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 5784
final_rank: 14

code_snippet: #include<iostream>
#include<iomanip>
#include<vector>
#include<cmath>
using namespace std;
struct Point{
	double x,y;
};
int n;
Point a[11111];
Point b[11111];
void conv(double theta)
{
	double C=cos(-theta);
	double S=sin(-theta);
	for(int i=0;i<n;i++)
	{
		b[i].x=a[i].x*C-a[i].y*S;
		b[i].y=a[i].x*S+a[i].y*C;
	}
}
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i].x>>a[i].y;
	double ans=1e150;
	for(int i=0;i<n;i++)
	{
		int I=(i+1)%n;
		double now=hypot(a[I].x-a[i].x,a[I].y-a[i].y);
		double theta=atan2(a[I].y-a[i].y,a[I].x-a[i].x);
		//cout<<theta<<endl;
		conv(theta+5*M_PI/6);
		if(0&&i==0)
		{
			cout<<endl<<"debug"<<endl;
			for(int j=0;j<n;j++)cout<<b[j].x<<" "<<b[j].y<<endl;
			cout<<"debug"<<endl;
		}
		//double mx=1e150;
		//for(int j=0;j<n;j++)mx=min(mx,i==j?1e150:b[j].x-b[i].x);
		double mx=0;
		for(int j=0;j<n;j++)mx=max(mx,b[j].x-b[i].x);
		//cout<<mx<<" ";
		now+=mx/cos(M_PI/6);
		conv(theta+M_PI/6);
		if(0&&i==0)
		{
			cout<<endl<<"debug"<<endl;
			for(int j=0;j<n;j++)cout<<b[j].x<<" "<<b[j].y<<endl;
			cout<<"debug"<<endl;
		}
		mx=0;
		for(int j=0;j<n;j++)mx=max(mx,I==j?0:b[j].x-b[I].x);
		//cout<<mx<<endl;
		now+=mx/cos(M_PI/6);
		ans=min(ans,now);
	}
	cout<<fixed<<setprecision(9)<<ans<<endl;
}
accuracy: 1
time_ms: 380
memory_kb: 4028
final_rank: 9

code_snippet: #include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;
#define double long double
double px[10000], py[10000];
int N;
int argmax(double* arr) {
    double maxval;
    int maxindex = -1;
    for (int i=0; i<N; i++) {
        if (maxindex == -1 || maxval < arr[i]) {
            maxval = arr[i];
            maxindex = i;
        }
    }
    return maxindex;
}

double solve(double ax, double ay, double ux, double uy, double bx, double by, double vx, double vy) {
    // solve a + su = b + tv
    // su - tv = b - a
    // (s, t) = (u, -v).inv @ (b-a)
    double mat[2][2] = {
        { ux, -vx },
        { uy, -vy }
    };
    double det = mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0];
    //cout << "det:" << det << endl;
    double idet = 1 / det;
    double inv[2][2] = {
        { idet * mat[1][1], -idet * mat[0][1] },
        { -idet * mat[1][0], idet*mat[0][0] }};
    double s = inv[0][0] * (bx-ax) + inv[0][1] * (by-ay);
    double t = inv[1][0] * (bx-ax) + inv[1][1] * (by-ay);
    //cout << "st" << s << " " << t << endl;
    double xx = ax + s * ux;
    double yy = ay + s * uy;
    //cerr << xx << " " << yy << endl;
    //cerr << bx+t*vx << " " << by+t*vy << endl;
    return sqrt((xx-ax) * (xx-ax) + (yy-ay)*(yy-ay));

}

double calc(double base_rad) {
    double farA[10000], farB[10000], farC[10000];

    double cosA = cos(base_rad + M_PI*2/3);
    double sinA = sin(base_rad + M_PI*2/3);
    double cosB = cos(base_rad - M_PI*2/3);
    double sinB = sin(base_rad - M_PI*2/3);
    double cosC = cos(base_rad);
    double sinC = sin(base_rad);
    // transform
    for (int i=0; i<N; i++) {
        farA[i] = px[i] * cosA + py[i] * sinA;
        farB[i] = px[i] * cosB + py[i] * sinB;
        farC[i] = px[i] * cosC + py[i] * sinC;
        //cout << farA[i] << endl;
        //cout << farB[i] << endl;
        //cout << farC[i] << endl;
        //cout << endl;
    }
    int maxAindex = argmax(farA);
    int maxBindex = argmax(farB);
    int maxCindex = argmax(farC);
    double pax = px[maxAindex];
    double pay = py[maxAindex];
    double pbx = px[maxBindex];
    double pby = py[maxBindex];
    double pcx = px[maxCindex];
    double pcy = py[maxCindex];
    double vecAx = -sinA;
    double vecAy = cosA;
    double vecBx = -sinB;
    double vecBy = cosB;
    double vecCx = -sinC;
    double vecCy = cosC;
    //cout << "vecC " << vecCx << "," << vecCy << endl;
    double val = solve(pcx, pcy, vecCx, vecCy, pbx, pby, vecBx, vecBy) + solve(pcx, pcy, vecCx, vecCy, pax, pay, vecAx, vecAy);
    return val;
}

int main() {
    cin >> N;
    for (int i=0; i<N; i++) cin >> px[i] >> py[i];

    const int try_n = 10000;
    const int try2_n = 10000;
    double minval = -1;
    double minrad = 0;

    for (int try_i = 0; try_i < try_n; try_i++) {
        double base_rad = try_i * M_PI * 2 / 3 / try_n;
        double val = calc(base_rad);
        if (minval == -1 || val < minval) {
            minval = val;
            minrad = base_rad;
        }
    }
    double rad_from = minrad - M_PI * 2 / 3 / try_n;
    double rad_to = minrad + M_PI * 2 / 3 / try_n;
    for (int try_i = 0; try_i < try2_n; try_i++) {
        double base_rad = rad_from + (rad_to - rad_from) * try_i / try2_n;
        double val = calc(base_rad);
        if (minval == -1 || val < minval) {
            minval = val;
            minrad = base_rad;
        }
    }
    cout << setprecision(15) << minval << endl;
        
    return 0;
}
accuracy: 1
time_ms: 1910
memory_kb: 4340
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define double long double

/* 基本要素 */
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> VP;
const double PI = acos(-1);
const double EPS = 1e-6; // 許容誤差^2
const double INF = 1e9;
#define X real()
#define Y imag()
#define LE(n,m) ((n) - (m) < EPS)
#define GE(n,m) (EPS > (m) - (n))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

// 外積　cross(a,b) = |a||b|sinθ
double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

// 点の進行方向
// !!! 誤差に注意 !!! (掛け算したものとかなり小さいものを比べているので)
int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

// 2直線の交点
Point crosspointLL(Point a1, Point a2, Point b1, Point b2) {
  double d1 = cross(b2-b1, b1-a1);
  double d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;  // same line
  assert(!EQ(d2, 0)); // 交点がない
  return a1 + d1/d2 * (a2-a1);
}

using Vector = Point;

Point READ(){
    double x,y;
    cin >>x >>y;
    return Point(x,y);
}

double calct(Point a, Point b, Point c, Vector u){
    Vector v = b-a;
    Point cp = crosspointLL(a,b,c,c+u);

    double t;
    if(EQ(v.X, 0)){
        if( EQ(v.Y, 0) ){
            while(1){}
        }

        t = (cp.Y - a.Y)/v.Y;
    }
    else{
        t = (cp.X - a.X)/v.X;
    }
    return t;
}

int main(){
    int n;
    cin >>n;

    VP p(n);
    rep(i,n) p[i] = READ();

    double ans = 1e12;
    int min_idx = 0, max_idx = 0;
    double mnt = INF, mxt = -INF;
    rep(i,n){
        Point a = p[0], b = p[1];
        Vector v = b-a;

        Vector mnv = v * polar((double)1.0, -2*PI/3);
        Vector mxv = v * polar((double)1.0, -PI/3);

        Point c = p[i];

        double tt = calct(a,b,c,mnv);
        if(tt < mnt){
            mnt = tt;
            min_idx = i;
        }

        tt = calct(a,b,c,mxv);
        if(tt > mxt){
            mxt = tt;
            max_idx = i;
        }
        ans = abs( (a+mnt*v) - (a+mxt*v) );
    }

    // dbg(ans);
    // printf(" 0 : min %d max %d\n", min_idx, max_idx);

    for(int i=1; i<n; ++i){
        Point a = p[i], b = p[(i+1)%n];
        Vector v = b-a;

        Vector mnv = v * polar((double)1.0, -2*PI/3);
        Vector mxv = v * polar((double)1.0, -PI/3);
        // dbg(v);
        // dbg(mnv);
        // dbg(mxv);

        rep(loop,n){
            double pt = calct(a,b,p[min_idx],mnv);
            double qt = calct(a,b,p[(min_idx+1)%n],mnv);

            if(qt > pt+EPS) break;
            min_idx = (min_idx+1)%n;
        }

        rep(loop,n){
            double pt = calct(a,b,p[max_idx],mxv);
            double qt = calct(a,b,p[(max_idx+1)%n],mxv);

            if(qt < pt-EPS) break;
            max_idx = (max_idx+1)%n;
        }

        // printf(" %d : min %d max %d\n", i,min_idx, max_idx);

        mnt = calct(a,b,p[min_idx],mnv);
        mxt = calct(a,b,p[max_idx],mxv);
        double dd = abs( (a+mnt*v) - (a+mxt*v) );
        ans = min(ans, dd);
    }

    printf("%.10Lf\n", ans);
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3336
final_rank: 3

code_snippet: #include<iostream>
#include<complex>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<double,double> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
typedef complex<double> P;
typedef vector<P> G;
typedef vector<double> vd;
typedef vector<vd> vvd;

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
struct C{
	P c;double r;
	C(const P &c,double r):c(c),r(r){}
};
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define diff(P, i) (next(P, i) - curr(P, i))
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
		//return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);  
	}
	bool operator == (const P& a, const P& b) {
		return a.real()==b.real()&&a.imag()==b.imag();
	}
}
P pin(){
	double x,y;
	char d;
	cin>>x>>y;
	P p(x,y);
	return p;
}
void PIN(P* a,int n){
	rep(i,n)a[i]=pin();
}
double dot(P a,P b){
	return real(conj(a)*b);
}
double cross(P a,P b){
	return imag(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;                               // a--c--b on line
}
P projection(L a,P p){
	double t=dot(p-a[0],a[0]-a[1])/norm(a[0]-a[1]);
	return a[0]+t*(a[0]-a[1]);
}
P reflection(L a,P p){
	return p+2.0*(projection(a,p)-p);
}
bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
double distanceLP(const L &l, const P &p) {
	return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
  return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
  if (intersectLS(l, s)) return 0;
  return min(distanceLP(l, s[0]), distanceLP(l, s[1]));
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
/*bool intersectCS(C c,const L &l){
    return (distanceLP(l,c.c) < c.r+EPS &&
            (c.r < abs(c.c-l[0]) + EPS || c.r < abs(c.c-l[1]) + EPS));
}*/
int intersectCS(C c,L l){
	if(norm(projection(l,c.c)-c.c)-c.r*c.r>EPS)return 0;
	const double d1=abs(c.c-l[0]),d2=abs(c.c-l[1]);
	if(d1<c.r+EPS&&d2<c.r+EPS)return 0;
	if(d1<c.r-EPS&&d2>c.r+EPS||d1>c.r+EPS&&d2<c.r-EPS)return 1;
	const P h=projection(l,c.c);
	if(dot(l[0]-h,l[1]-h)<0)return 2;
	return 0;
}
P crosspointSS(L a,L b){
	double t1=abs(cross(a[1]-a[0],b[0]-a[0]));
	double t2=abs(cross(a[1]-a[0],b[1]-a[0]));
	return b[0]+(b[1]-b[0])*t1/(t1+t2);
}
L crosspointCL(C c,L l){
	P pr=projection(l,c.c);
	P e=(l[1]-l[0])/abs(l[1]-l[0]);
	double tmp=c.r*c.r-norm(pr-c.c);
	if(abs(tmp)<EPS)tmp=0;
	double t=sqrt(tmp);
	P a=pr+t*e;
	P b=pr-t*e;
	if(b<a)swap(a,b);
	return L(a,b);
}
L crosspointCS(C c,L l){
	if(intersectCS(c,l)==2)return crosspointCL(c,l);
	L ret=crosspointCL(c,l);
	if(dot(l[0]-ret[0],l[1]-ret[0])<0)ret[1]=ret[0];
	else ret[0]=ret[1];
	return ret;
}
L crosspointCC(C a,C b){
	P tmp=b.c-a.c;
	double d=abs(tmp);
	double q=acos((a.r*a.r+d*d-b.r*b.r)/(2*a.r*d));
	double t=arg(tmp);//atan(tmp.imag()/tmp.real());
	P p1=a.c+polar(a.r,t+q);
	P p2=a.c+polar(a.r,t-q);
	if(p2<p1)swap(p1,p2);
	return L(p1,p2);
}
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]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  return m[0] + B / A * (m[1] - m[0]);
}
double area(const G &g){
    double S =0;
    for(int i =0;i <g.size();i++){
        S +=(cross(g[i],g[(i+1)%g.size()]));
    }
    return abs(S/2.0);
}
bool isconvex(const G &g){
	int n=g.size();
	rep(i,n)if(ccw(g[(i+n-1)%n],g[i%n],g[(i+1)%n])==-1)return false;
	return true;
}
int inconvex(const G& g, const P& p) {
	bool in = false;
	int n=g.size();
	rep(i,n){
		P a=g[i%n]-p;
		P b=g[(i+1)%n]-p;
		if(imag(a)>imag(b))swap(a, b);
		if(imag(a)<EPS&&0<imag(b))if(cross(a,b)<0)in=!in;
		if(abs(cross(a,b))<EPS&&dot(a,b)<EPS)return 1;//ON
	}
	return in?2:0;//IN : OUT;
}
G convex_hull(G &ps) {
    int n=ps.size(),k=0;
	sort(ps.begin(), ps.end());
	G ch(2*n);
	for(int i=0;i<n;ch[k++]=ps[i++])//lower-hull
		while(k>=2&&ccw(ch[k-2],ch[k-1],ps[i])==-1)--k;//<=0  ->  ==-1
	for(int i=n-2,t=k+1;i>=0;ch[k++]=ps[i--])//upper-hull
		while(k>=t&&ccw(ch[k-2],ch[k-1],ps[i])==-1)--k;//
	ch.resize(k-1);
	return ch;
}
double convex_diameter(const G &pt) {
  const int n = pt.size();
  int is = 0, js = 0;
  for (int i = 1; i < n; ++i) {
    if (imag(pt[i]) > imag(pt[is])) is = i;
    if (imag(pt[i]) < imag(pt[js])) js = i;
  }
  double maxd = norm(pt[is]-pt[js]);

  int i, maxi, j, maxj;
  i = maxi = is;
  j = maxj = js;
  do {
    if (cross(diff(pt,i), diff(pt,j)) >= 0) j = (j+1) % n;
    else i = (i+1) % n;
    if (norm(pt[i]-pt[j]) > maxd) {
      maxd = norm(pt[i]-pt[j]);
      maxi = i; maxj = j;
    }
  } while (i != is || j != js);
  return sqrt(maxd); /* farthest pair is (maxi, maxj). */
}//convex_diameter(g)
G convex_cut(const G& g, const L& l) {
  G Q;
  for (int i = 0; i < g.size(); ++i) {
    P a= curr(g, i), b= next(g, i);
    if (ccw(l[0], l[1], a) != -1) Q.push_back(a);
    if (ccw(l[0], l[1], a)*ccw(l[0], l[1], b) < 0)
      Q.push_back(crosspointLL(L(a,b), l));
  }
  return Q;
}
P turn(P p,double t){
	return p*exp(P(.0,t*PI/180.0));
}
P turn2(P p,double t){
	return p*exp(P(.0,t));
}
vector<L> tangentCC(C a,C b){
	if(a.r<b.r)swap(a,b);
	double d=abs(a.c-b.c);
	vector<L>l;
	if(d<EPS)return l;
	if(a.r+b.r<d-EPS){//hanareteiru
		double t=acos((a.r+b.r)/d);
		t=t*180/PI;
		l.pb(L(a.c+turn(a.r/d*(b.c-a.c),t),b.c+turn(b.r/d*(a.c-b.c),t)));
		l.pb(L(a.c+turn(a.r/d*(b.c-a.c),-t),b.c+turn(b.r/d*(a.c-b.c),-t)));
	}else if(a.r+b.r<d+EPS){//kuttuiteiru soto
		P p=a.c+a.r/d*(b.c-a.c);
		l.pb(L(p,p+turn(b.c-a.c,90)));
	}
	if(abs(a.r-b.r)<d-EPS){//majiwatteiru
		double t1=acos((a.r-b.r)/d);
		t1=t1*180/PI;
		double t2=180-t1;
		l.pb(L(a.c+turn(a.r/d*(b.c-a.c),t1),b.c+turn(b.r/d*(a.c-b.c),-t2)));
		l.pb(L(a.c+turn(a.r/d*(b.c-a.c),-t1),b.c+turn(b.r/d*(a.c-b.c),t2)));
	}else if(abs(a.r-b.r)<d+EPS){//kuttuiteiru uti
		P p=a.c+a.r/d*(b.c-a.c);
		l.pb(L(p,p+turn(b.c-a.c,90)));
	}
	return l;
}
void printL(const L &out){
	printf("%0.9f %0.9f %0.9f %0.9f\n",out[0].real(),out[0].imag(),out[1].real(),out[1].imag());
}
C CIN(){
	P p=pin();
	double r;
	cin>>r;
	return C(p,r);
}
bool para(L a,L b){
	return (abs(cross(a[1]-a[0],b[1]-b[0]))<EPS);
}
//余弦定理
double LawOfCosines(double a,double b,double c){
	return acos((b*b+c*c-a*a)/(2.*b*c));
}
//外接円
pair<P,double> circumccircle(P a,P b,P c){
	double dA=abs(b-c),dB=abs(a-c),dC=abs(a-b);
	double angA=LawOfCosines(dA,dB,dC);
	double angB=LawOfCosines(dB,dC,dA);
	double angC=LawOfCosines(dC,dA,dB);
	double A=sin(2.*angA),B=sin(2.*angB),C=sin(2.*angC);
	double x=(a.real()*A+b.real()*B+c.real()*C)/(A+B+C);
	double y=(a.imag()*A+b.imag()*B+c.imag()*C)/(A+B+C);
	P p(x,y);
	double r=dA/sin(angA)/2.;
	return {p,r};
}
//内接円
pair<P,double> incircle(P a,P b,P c){
	double dA=abs(b-c),dB=abs(a-c),dC=abs(a-b);
	L l1(a,b+dC/(dB+dC)*(c-b));
	L l2(b,a+dC/(dA+dC)*(c-a));
	P p=crosspointLL(l1,l2);
	double r=abs(p-projection(L(a,b),p));
	return {p,r};
}
int n;
G g;
pii f(int i,int it){
	L l(g[i],g[(i+1)%n]);
	pii out;
	P b=(g[(i+1)%n]-g[i])/abs(g[(i+1)%n]-g[i]);
	{
		P p=projection(l,g[it])-g[it];
		p=turn(p,-30);
		out.first=dot(b,crosspointLL(l,L(g[it],g[it]+p))-g[i]);
	}
	{
		P p=projection(l,g[it])-g[it];
		p=turn(p,30);
		out.second=dot(b,crosspointLL(l,L(g[it],g[it]+p))-g[i]);
	}
	return out;
}
int main(){
	cin>>n;
	g=G(n);
	rep(i,n)g[i]=pin();
	
	int lit=-1,rit=-1;
	pii t;
	rep(j,n){
		pii w=f(0,j);
		cmax(t.first,-w.first);
		cmax(t.second,w.second);
	}
	rep(j,n){
		pii w=f(0,j);
		if(abs(t.first+w.first)<EPS)lit=j;
		if(abs(t.second-w.second)<EPS)rit=j;
	}
	double out=t.first+t.second;
	loop(i,1,n){
		while(1){
			if(f(i,lit).first>f(i,(lit+1)%n).first)(lit+=1)%=n;
			else break;
		}
		while(1){
			if(f(i,rit).second<f(i,(rit+1)%n).second)(rit+=1)%=n;
			else break;
		}
		cmin(out,-f(i,lit).first+f(i,rit).second);
	}
	cout<<shosu(9)<<out<<endl;
}
accuracy: 1
time_ms: 30
memory_kb: 3336
final_rank: 4

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>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ld INF = (ld)10000000000;
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++)
typedef complex<ld> Point;
const ld eps = 1e-7;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;

//外心を求める。3点が同一直線上だとRE
LDP cent(LDP a[3]) {
	ld x[2], y[2];
	rep(i, 2) {
		x[i] = a[i + 1].first - a[0].first;
		y[i] = a[i + 1].second - a[0].second;
	}
	ld bunbo = 2 * (x[0] * y[1] - y[0] * x[1]);
	ld cx = (x[0] * x[0] * y[1] + y[0] * y[0] * y[1] - y[0] * x[1] * x[1] - y[0] * y[1] * y[1]) / bunbo;
	ld cy = (x[0] * x[1] * x[1] + x[0] * y[1] * y[1] - x[0] * x[0] * x[1] - y[0] * y[0] * x[1]) / bunbo;
	return { cx + a[0].first,cy + a[0].second };
}


bool eq(ld a, ld b) {
	return (abs(a - b) < eps);
}
//内積
ld dot(Point a, Point b) {
	return real(conj(a)*b);
}
//外積
ld cross(Point a, Point b) {
	return imag(conj(a)*b);
}
//線分
//直線にするなら十分通い２点を端点とすればよい
class Line {
public:
	Point a, b;
};
//円
class Circle {
public:
	Point p;
	ld r;
};
//3点の位置関係
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の順に一直線
}
//2直線の交差判定
bool isis_ll(Line l, Line m) {
	return !eq(cross(l.b - l.a, m.b - m.a), 0);
}
//直線と線分の交差判定
bool isis_ls(Line l, Line s) {
	return (cross(l.b - l.a, s.a - l.a)*cross(l.b - l.a, s.b - l.a) < eps);
}
//点が直線上に存在するか
bool isis_lp(Line l, Point p) {
	return (abs(cross(l.b - p, l.a - p)) < eps);
}
//点が線分上に存在するか
bool isis_sp(Line s, Point p) {
	return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}
//線分と線分の交差判定
bool isis_ss(Line s, Line t) {
	if (isis_sp(s, t.a) || isis_sp(s, t.b) || isis_sp(t, s.a) || isis_sp(t, s.b))return true;
	return(cross(s.b - s.a, t.a - s.a)*cross(s.b - s.a, t.b - s.a) < -eps && cross(t.b - t.a, s.a - t.a)*cross(t.b - t.a, s.b - t.a) < -eps);
}
//点から直線への垂線の足
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);
}
//直線と直線の交点
//平行な２直線に対しては使うな！！！！
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);
}
//直線と点の距離
ld dist_lp(Line l, Point p) {
	return abs(p - proj(l, p));
}
//直線と直線の距離
ld dist_ll(Line l, Line m) {
	return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}
//線分と直線の距離
ld dist_ls(Line l, Line s) {
	return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}
//線分と点の距離
ld dist_sp(Line s, Point p) {
	Point r = proj(s, p);
	return isis_sp(s, r) ? abs(p - r) : min(abs(p - s.a), abs(p - s.b));
}
//線分と線分の距離
ld dist_ss(Line s, Line t) {
	if (isis_ss(s, t))return 0;
	return min({ dist_sp(s,t.a),dist_sp(s,t.b),dist_sp(t,s.a),dist_sp(t,s.b) });
}

int n;
Point p[10001];
const ld th = pi / 3;
int main() {
	cout << fixed << setprecision(6);
	cin >> n;
	rep(i, n) {
		ld x, y; cin >> x >> y;
		p[i] = { x,y };
	}
	p[n] = p[0];
	ld out = INF;
	int l = 1, r = 1;
	rep(i, n) {
		Point d = p[i + 1] - p[i];
		Point d1 = d * Point{ cos(th),sin(th) };
		Point d2 = d * Point{ cos(-th),sin(-th) };
		Point x1 = p[i] + Point{ -INF * real(d1),-INF * imag(d1) };
		Point x2 = p[i] + Point{ INF * real(d1),INF * imag(d1) };
		Point y1 = p[i + 1] + Point{ -INF * real(d2),-INF * imag(d2) };
		Point y2 = p[i + 1] + Point{ INF*real(d2),INF*imag(d2) };
		Line l1 = { x1,x2 }, l2 = { y1,y2 };
		while (r!=i&&ccw(x1, p[r], x2) != -1) {
			r = (r + 1) % n;
		}
		while (r != i) {
			ld le = dist_lp(l1, p[r]);
			ld ri = dist_lp(l1, p[(r+1)%n]);
			if (le < ri)r = (r + 1) % n;
			else break;
		}
		ld ans = abs(p[i + 1] - p[i]);
		ans += max((ld)0,dist_lp(l1,p[r]) * 2 / sqrt(3.0));
		/*while (l != i + 1 && ccw(y1, p[l], y2) != -1) {
			l = (l - 1+n) % n;
		}*/
		if (l == i)l = (l + 1) % n;
		while (ccw(y1, p[(l + 1) % n],y2) == -1) {
			ld le = dist_lp(l2, p[l]);
			ld ri = dist_lp(l2, p[(l + 1) % n]);
			if (le < ri)l = (l + 1) % n;
			else break;
		}
		ans += max(ld(0),dist_lp(l2,p[l]) * 2 / sqrt(3.0));
		out = min(out, ans);
	}
	cout << out << endl;
	//stop
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3636
final_rank: 5

code_snippet: #include <algorithm>
#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<P,double> C;
typedef vector<P> Poly;
#define X real()
#define Y imag()
const double EPS = (1e-10), pi = acos(-1);

namespace std{
  bool operator < (const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
  bool cmp_y(const P &a, const P &b){
    return a.Y != b.Y ? a.Y < b.Y : a.X < b.X;
  }
  bool operator == (const P& a, const P& b){
    return abs(a-b) < EPS;
  }
}

double dot(P a, P b){ return a.X * b.X + a.Y * b.Y;}
double cross(P a, P b){ return a.X * b.Y - a.Y * b.X;}
P projection(P a, P b){ return dot(a, b)/abs(b)/abs(b)*b;}

P intersection(L a, L b){
  //直線aと直線bの交点
  P af = a.first, as = a.second, bf = b.first, bs = b.second;
  return af + cross(bs-bf,af-bf)/(-cross(bs-bf,as-bf)+cross(bs-bf,af-bf))*(as-af);
}

int main(){
  int N;
  cin >> N;
  Poly pol;
  for(int i = 0; i < N; ++i){
    double x, y;
    cin >> x >> y;
    pol.emplace_back(x,y);
  }
  double ans = 1e18;
  P r(cos(-pi/3),sin(-pi/3));
  for(int i = 0; i < N; ++i){
    L l(pol[i],pol[(i+1)%N]);
    P d = pol[(i+1)%N]-pol[i];
    //cerr << d << endl
    double ma = abs(d), mi = 0;
    d /= abs(d);
    for(int j = 0; j < N; ++j){
      if(j == i or j == (i+1)%N) continue;
      L l1(pol[j],pol[j]+d*r), l2(pol[j],pol[j]+d*r*r);
      P a = intersection(l,l1), b = intersection(l,l2);

      ma = max(ma,dot(a-pol[i],d));
      ma = max(ma,dot(b-pol[i],d));
      mi = min(mi,dot(a-pol[i],d));
      mi = min(mi,dot(b-pol[i],d));
    }
    ans = min(ans,ma-mi);
  }
  printf("%.12f\n",ans);
}
accuracy: 1
time_ms: 1650
memory_kb: 3352
final_rank: 12

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_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



typedef complex<double> Point;

const double A=(double)1/sqrt(3);

double R_cul(Point a,Point b,Point p){
    p-=a;
    b-=a;
    b/=abs(b);
    p/=b;
    return p.real()+A*p.imag();
}

double L_cul(Point a,Point b,Point p){
    p-=b;
    a-=b;
    a/=abs(a);
    p/=a;
    return p.real()-A*p.imag();
}


int main(){
    ll n;
    cin>>n;
    vector<Point> P(n); //反時計回りを仮定
    for(auto &I:P){
        double x,y;
        cin>>x>>y;
        I={x,y};
    }
    ll l=0,r=1;
    while(R_cul(P[0],P[1],P[r])<=R_cul(P[0],P[1],P[(r+1)%n])){r=(r+1)%n;}
    while(L_cul(P[0],P[1],P[l])<=L_cul(P[0],P[1],P[(l+n-1)%n])){l=(l+n-1)%n;}
    double ans=R_cul(P[0],P[1],P[r])+L_cul(P[0],P[1],P[l])-abs(P[1]-P[0]);
    for(ll i=1;i<n;i++){
        while(R_cul(P[i],P[(i+1)%n],P[r])<=R_cul(P[i],P[(i+1)%n],P[(r+1)%n])){r=(r+1)%n;}
        while(L_cul(P[i],P[(i+1)%n],P[l])<=L_cul(P[i],P[(i+1)%n],P[(l+1)%n])){l=(l+1)%n;}
        ans=min(ans,R_cul(P[i],P[(i+1)%n],P[r])+L_cul(P[i],P[(i+1)%n],P[l])-abs(P[i]-P[(i+1)%n]));
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
    
    
    
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3304
final_rank: 1

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_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



typedef complex<double> Point;

const double A=(double)1/sqrt(3);

double R_cul(Point a,Point b,Point p){
    p-=a;
    b-=a;
    b/=abs(b);
    p/=b;
    return p.real()+A*p.imag();
}

double L_cul(Point a,Point b,Point p){
    p-=b;
    a-=b;
    a/=abs(a);
    p/=a;
    return p.real()-A*p.imag();
}


int main(){
    ll n;
    cin>>n;
    vector<Point> P(n); //反時計回りを仮定
    for(auto &I:P){
        double x,y;
        cin>>x>>y;
        I={x,y};
    }
    ll l=0,r=1;
    while(R_cul(P[0],P[1],P[r])<=R_cul(P[0],P[1],P[(r+1)%n])){r=(r+1)%n;}
    while(L_cul(P[0],P[1],P[l])<=L_cul(P[0],P[1],P[(l+n-1)%n])){l=(l+n-1)%n;}
    double ans=R_cul(P[0],P[1],P[r])+L_cul(P[0],P[1],P[l])-abs(P[1]-P[0]);
    for(ll i=1;i<n;i++){
        while(R_cul(P[i],P[(i+1)%n],P[r])<=R_cul(P[i],P[(i+1)%n],P[(r+1)%n])){r=(r+1)%n;}
        while(L_cul(P[i],P[(i+1)%n],P[l])<=L_cul(P[i],P[(i+1)%n],P[(l+1)%n])){l=(l+1)%n;}
        ans=min(ans,R_cul(P[i],P[(i+1)%n],P[r])+L_cul(P[i],P[(i+1)%n],P[l])-abs(P[i]-P[(i+1)%n]));
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
    
    
    
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3304
final_rank: 1