1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,tn=0;
pii a[SZ],b[SZ],t[SZ];
pair<ld,ld> ps[SZ]; int pn=0;
namespace Hpi
{
int m,L,R;
struct P{ld x,y;};
struct line{P a,b;ld slop;}l[200010],a[200010],q[200010];
P operator-(P a,P b)
{
	P t;t.x=a.x-b.x;t.y=a.y-b.y;return t;
}
ld cal(ld a,ld b,int x)
{
	return b/a-a*x;
}
ld operator*(P a,P b)
{
	return a.x*b.y-a.y*b.x;
}
bool operator<(line a,line b)
{
	if(a.slop==b.slop)return (a.b-a.a)*(b.a-a.a)>0;
	return a.slop<b.slop;
}
P inter(line a,line b)
{
	ld k1,k2,t;
	k1=(b.b-a.a)*(a.b-a.a);
	k2=(a.b-a.a)*(b.a-a.a);
	t=k2/(k1+k2);
	P p;
	p.x=b.a.x+t*(b.b.x-b.a.x);
	p.y=b.a.y+t*(b.b.y-b.a.y);
	return p;
}
const ld eps=1e-12;
bool jud(line a,line b,line t)
{
	P p=inter(a,b);
	return (p-t.a)*(t.b-t.a)>-eps;
}
void hpi()
{
	int cnt=0;
	for(int i=1;i<=m;i++)
	{
//		if(l[i].slop!=a[cnt].slop) ++cnt;
		if(fabs(l[i].slop-a[cnt].slop)>eps) cnt++;
		a[cnt]=l[i];
	}
	L=1,R=0;
	q[++R]=a[1];q[++R]=a[2];
	for(int i=3;i<=cnt;i++)
	{
		while(L<R&&jud(q[R-1],q[R],a[i]))R--;
		while(L<R&&jud(q[L+1],q[L],a[i]))L++;
		q[++R]=a[i];
	}
	while(L<R&&jud(q[R-1],q[R],q[L]))R--;
	while(L<R&&jud(q[L+1],q[L],q[R]))L++;
}
void init()
{
	const ld linf=1e15;
	l[++m].a=(P){-linf,-linf};l[m].b=(P){linf,-linf};
	l[++m].a=(P){linf,-linf};l[m].b=(P){linf,linf};
	l[++m].a=(P){linf,linf};l[m].b=(P){-linf,linf};
	l[++m].a=(P){-linf,linf};l[m].b=(P){-linf,-linf};
}
void push(ld a,ld b,ld c)
{
	//a*x+b*y>=c
	//t.b-t.a=(-b,a)
	//t.a*(-b,a)=c
	//(c/a,0)*(-b,a)
	//(0,c/b)*(-b,a) 
	line g;
	memset(&g,0,sizeof g);
	if(fabs(a)>fabs(b))
		g.a.x=c/a;
	else g.a.y=c/b;
	g.b.x=g.a.x+b;
	g.b.y=g.a.y-a;
	l[++m]=g;
}
P t[SZ];
void work()
{
	for(int i=1;i<=m;i++)
		l[i].slop=atan2(l[i].b.y-l[i].a.y,l[i].b.x-l[i].a.x);
	sort(l+1,l+m+1);
	hpi();
	ld area=0;
	if(R-L>=2)
	{
		for(int i=L;i<=R;++i)
			t[i]=inter(q[i],q[(i==R)?L:(i+1)]);
		for(int i=L;i<=R;++i)
			area+=t[i]*t[(i==R)?L:(i+1)];
		area=fabs(area); area/=2.0;
	}
	printf("%.10lf\n",(double)area);
}
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i].fi>>a[i].se>>b[i].fi>>b[i].se,
		t[++tn]=a[i],t[++tn]=b[i];
	Hpi::init();
	ps[++pn]=mp(1,0);
	ps[++pn]=mp(-1,0);
	ps[++pn]=mp(0,1);
	ps[++pn]=mp(0,-1);
	for(int i=1;i<=tn;++i)
		for(int j=i+1;j<=tn;++j)
		{
			//(t[i].fi-t[j].fi)*co+(t[i].se-t[j].se)*si=0
			ld co=t[i].se-t[j].se,si=t[j].fi-t[i].fi;
			ld l=sqrtl(co*co+si*si);
			co/=l,si/=l;
			ps[++pn]=mp(co,si);
			ps[++pn]=mp(si,-co);
			ps[++pn]=mp(-co,-si);
			ps[++pn]=mp(-si,co);
		}
//	sort(ps+1,ps+1+pn);
//	pn=unique(ps+1,ps+1+pn)-ps-1;
	for(int i=1;i<=pn;++i)
	{
		ld co=ps[i].fi,si=ps[i].se,mi=8e18;
		for(int j=1;j<=n;++j)
			mi=min(mi,max(a[j].fi*co+a[j].se*si,
			b[j].fi*co+b[j].se*si));
		Hpi::push(co,si,mi);
//		cout<<co<<","<<si<<":"<<mi<<"\n";
	}
	Hpi::work();
}