Pro.ID21643 TitleCutting Rectangles Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21643 AC0 Submit0 Ratio- 时间&空间限制描述There are several solid rectangles with their edges paralleled to the coordinate axes on the plane, little Bug draws several segments parallel to the x-axis, and he wants to know the sum of the number of solid rectangles that are cut by these segments. We say that a solid rectangle is cut by a segment if and only if they share at least one point. If a solid rectangle is cut by K segments, it will be calculated K times. 输入The first line of input will be a positive integer T ≤ 20, T test cases follow. The first line of each test case will be a positive integer N ≤ 30000, the number of solid rectangles. Then N lines follow, each line contains four non-negative integers: x1, y1, x2, y2, representing the lower left and upper right coordinates of the solid rectangle. It's guaranteed that x1 < x2 and y1 < y2. After that there will be a positive integer Q ≤ 30000, which is the number of segments. Then Q lines follow, each line contains four non-negative integers: x3, y3, x4, y4, representing the coordinates of the two end points of the segment, It's guaranteed that x3 < x4 and y3 = y4, All integers given are not greater than 100,000,000. 输出Description There are several solid rectangles with their edges paralleled to the coordinate axes on the plane, little Bug draws several segments parallel to the x-axis, and he wants to know the sum of the number of solid rectangles that are cut by these segments. We say that a solid rectangle is cut by a segment if and only if they share at least one point. If a solid rectangle is cut by K segments, it will be calculated K times. Input The first line of input will be a positive integer T ≤ 20, T test cases follow. The first line of each test case will be a positive integer N ≤ 30000, the number of solid rectangles. Then N lines follow, each line contains four non-negative integers: x1, y1, x2, y2, representing the lower left and upper right coordinates of the solid rectangle. It's guaranteed that x1 < x2 and y1 < y2. After that there will be a positive integer Q ≤ 30000, which is the number of segments. Then Q lines follow, each line contains four non-negative integers: x3, y3, x4, y4, representing the coordinates of the two end points of the segment, It's guaranteed that x3 < x4 and y3 = y4, All integers given are not greater than 100,000,000. Output For each test case, output one integer on one line, the sum of the number of solid rectangles that are cut by these segments. Sample Input 1 Sample Output 3 Source 样例输入1 样例输出3 作者 |