转成半平面交就好了。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#define eps 1e-7
#define maxn 100021
using namespace std;
int n,tot,cnt;
struct P{
double x,y;
P(double a=0,double b=0):x(a),y(b){}
}p[maxn],a[maxn];
typedef P vec;
vec operator-(P a,P b){return vec(a.x-b.x,a.y-b.y);}
double operator*(vec a,vec b){return a.x*b.y-a.y*b.x;}
P operator+(P a,P b){return P(a.x+b.x,a.y+b.y);}
vec operator*(vec a,double b){return vec(a.x*b,a.y*b);}
struct Line{
P fr,sc;double slop;
void init(P x,P y){
fr=x,sc=y;
slop=atan2(sc.y-fr.y,sc.x-fr.x);
}
bool operator<(const Line& b)const {
if(slop!=b.slop)return slop<b.slop;
return (sc-fr)*(b.sc-fr)<0;
}
}l[maxn],q[maxn*2];
P insert(Line xx,Line yy){
P a=xx.fr,b=xx.sc,x=yy.fr,y=yy.sc;
double s1=(b-a)*(y-a),s2=(x-a)*(b-a);
double t=s2/(s1+s2);
return x+(y-x)*t;
}
bool cheak(Line a,Line b,Line c){
P x=insert(a,b);
return (c.sc-c.fr)*(x-c.fr)<0;
}
void make(){
int L=1,R=1;q[L]=l[1];q[++R]=l[2];
for(int i=3;i<=cnt;i++){
while(L<R&&cheak(q[R-1],q[R],l[i]))R--;
while(L<R&&cheak(q[L],q[L+1],l[i]))L++;
q[++R]=l[i];
}
while(L<R&&cheak(q[R-1],q[R],q[L]))R--;
q[R+1]=q[L];
for(int i=L;i<=R;i++){
a[++tot]=insert(q[i],q[i+1]);
}
}
int main(){
scanf("%d",&n);
for(int k,i=1;i<=n;i++){
scanf("%d",&k);
for(int j=1;j<=k;j++)scanf("%lf%lf",&p[j].x,&p[j].y);
p[k+1]=p[1];
for(int j=1;j<=k;j++){
l[++cnt].init(p[j],p[j+1]);
}
}sort(l+1,l+1+cnt);
for(int i=1;i<=cnt;i++){
if(l[i].slop!=l[i-1].slop)
l[++tot]=l[i];
}cnt=tot;tot=0;
make();
if(tot<=2)return puts("0.000"),0;
double ans=0;a[tot+1]=a[1];
for(int i=1;i<=tot;i++){
ans+=a[i]*a[i+1];
}printf("%.3lf",fabs(ans)/2);
return 0;
}