#include #include #include #include using namespace std; const int MAX = 100; int main() { int N; double buildingArea[MAX], visibleArea[MAX]; int x1[MAX], y1[MAX], x2[MAX], y2[MAX]; cin >> N; assert(N >= 2 && N <= MAX); set xcoords; xcoords.insert(0); xcoords.insert(10000); for(int i=0;i> x1[i] >> y1[i] >> x2[i] >> y2[i]; assert(0 <= x1[i] && x1[i] < x2[i] && x2[i] <= 10000); assert(0 <= y1[i] && y1[i] <= 10000); assert(0 <= y2[i] && y2[i] <= 10000); xcoords.insert(x1[i]); xcoords.insert(x2[i]); buildingArea[i] = (x2[i]-x1[i])*(y1[i]+y2[i]) / 2.0; visibleArea[i] = 0.0; int v1x = x2[i]-x1[i], v1y = y2[i]-y1[i]; for(int j=0;j0 && fa0 && fb::iterator si=xcoords.begin();si!=xcoords.end();si++) { double current=*si; double covered=0.0; for(int i=0;i= current) { double slope = (double)(y2[i]-y1[i])/(x2[i]-x1[i]); double y3 = (last-x1[i])*slope+y1[i]; double y4 = (current-x1[i])*slope+y1[i]; double a = (current-last)*(y3+y4)/2.0; if (a - covered >= 0) visibleArea[i] += a - covered; if (a > covered) covered = a; } } last=current; } for(int i=0;i