頂點凸包+一個圓周長。
#include<bits/stdc++.h>
#define re register
#define cs const
cs int N=4e4+10;
cs double eps=1e-8,oo=1e9,pi=acos(-1);
struct Grid{
double x,y;
Grid(double X=0,double Y=0){x=X,y=Y;}
inline double Angle(){return atan2(y,x);}
inline double len(){return sqrt(x*x+y*y);}
friend inline Grid operator +(const Grid &a,const Grid &b){return Grid(a.x+b.x,a.y+b.y);}
friend inline Grid operator -(const Grid &a,const Grid &b){return Grid(a.x-b.x,a.y-b.y);}
friend inline Grid operator *(const Grid &a,const double &b){return Grid(a.x*b,a.y*b);}
friend inline Grid operator /(const Grid &a,const double &b){return Grid(a.x/b,a.y/b);}
friend inline double dot(const Grid &a,const Grid &b){return a.x*b.x+a.y*b.y;}
friend inline double cross(const Grid &a,const Grid &b){return a.x*b.y-a.y*b.x;}
inline Grid rotate(double ang){return Grid(x*cos(ang)-y*sin(ang),x*sin(ang)+y*cos(ang));}
}A[N],S[N];
typedef Grid Point,Vector;
inline int sgn(double x){
if(x>eps) return 1;
if(x<-eps) return -1;
return 0;
}
int n,tot,pos,top;double a,b,r,x,y,angle;
inline void get_pnts(cs Point &O,double ang){
A[++tot]=Vector( b, a).rotate(ang)+O;
if(A[0].y>A[tot].y||(A[0].y==A[tot].y&&A[0].x>A[tot].x)) A[0]=A[tot],pos=tot;
A[++tot]=Vector(-b, a).rotate(ang)+O;
if(A[0].y>A[tot].y||(A[0].y==A[tot].y&&A[0].x>A[tot].x)) A[0]=A[tot],pos=tot;
A[++tot]=Vector( b,-a).rotate(ang)+O;
if(A[0].y>A[tot].y||(A[0].y==A[tot].y&&A[0].x>A[tot].x)) A[0]=A[tot],pos=tot;
A[++tot]=Vector(-b,-a).rotate(ang)+O;
if(A[0].y>A[tot].y||(A[0].y==A[tot].y&&A[0].x>A[tot].x)) A[0]=A[tot],pos=tot;
}
inline bool cmp(cs Point &a,cs Point &b){
double P=atan2(a.y-A[1].y,a.x-A[1].x);
double Q=atan2(b.y-A[1].y,b.x-A[1].x);
return (P!=Q)?P<Q:a.x<b.x;
}
inline void Graham(){
std::swap(A[pos],A[1]),std::sort(A+2,A+tot+1,cmp);
S[1]=A[1],S[top=2]=A[2];
for(int re i=3;i<=tot;++i){
while(top>=3&&(cross(A[i]-S[top-1],S[top]-S[top-1])>=0)) --top;
S[++top]=A[i];
}S[top+1]=A[1];
}
double ans=0;
int main(){
scanf("%d%lf%lf%lf",&n,&a,&b,&r),a-=r*2,b-=r*2,a/=2.0,b/=2.0,A[0]=Point(oo,oo);
for(int re i=1;i<=n;++i) scanf("%lf%lf%lf",&x,&y,&angle),get_pnts(Point(x,y),angle);
Graham();
for(int re i=1;i<=top;++i) ans+=(S[i+1]-S[i]).len();
printf("%.2lf\n",ans+2.0*pi*r);
}