Cake Cutting

There is a very big rectangular (yes...) cake on the xy-plane, whose four corners are (0, 0), (w, 0), (w, h) and (0, h). Each time you’re hungry, you slice a piece from the cake and eat it. Your task is to output the area of the remaining cake, after each slice. Input There are several test cases. The first line contains threes integers n, w, h (1 ≤ n ≤ 200,000, 1 ≤ w, h ≤ 1000), the number of slices, the width and the height of the cake. Each of the following n lines contains four positive real numbers x1, y1, x2, y2 not greater than 1000. That means, you slice it along the straight line connecting (x1,y1) and (x2,y2), and eat the part on the right (if any), when looking from (x1, y1) to (x2, y2). The input is terminated by end-of-file (EOF). Output For each slice, output the area of the cake after the slice, to at least three digits after the decimal point. We allow an absolute error of 10−3 for each value you output. Sample Input 2 20 10 15.0 0.0 15.0 5.0 1.0 2.0 2.0 2.0 Sample Output 150.000 120.000