- محدودیت زمان: ۱ ثانیه
- محدودیت حافظه: ۲۵۶ مگابایت
Two farmers, Ahura and Mazda, want to plant vegetable crops on a shared land. Ahura always plants cucumbers, while Mazda always plants tomatoes.
They divide the land into n separate rectangles, with each rectangle aligned parallel to the and coordinate axes. Each of them then marks specific rectangles where they want plant their crops.
Ahura has chosen rectangles for planting cucumbers, and Mazda has chosen rectangles for planting tomatoes. we know we cant plant both cucumber and tomato in exactly one place. because of that, After marking their rectangles, they check for any overlapping areas on the land. To avoid conflicts, they agree not to plant anything in these overlapping areas. They will only plant cucumbers and tomatoes in the non-overlapping parts of their designated rectangles.
The goal is to calculate the difference in the area planted by each farmer. Let:
- represent the total area where Ahura will plants cucumbers,
- represent the total area where Mazda will plants tomatoes.
Your task is to compute and output this value
input
The first line contains a positive integer , the number of rectangles Ahura has chosen for planting cucumbers at first. The next lines each contains the two opposite corners of each rectangles, and , the bottom left corner and then , , representing the upper right corner coordinate of the rectangle designated by Ahura.
The following line contains a positive integer , the number of rectangles Mazda has chosen for planting tomatoes at first. The next lines each contains the two opposite corners of each rectangles, and , the bottom left corner and then , , representing the upper right corner coordinate of the rectangle designated by Mazda.
- It is guaranteed that Ahura's rectangles do not overlap with each other.
- It is guaranteed that Mazda's rectangles do not overlap with each other.
output
Output a single integer, the value of , which is the difference in the areas of land planted by Ahura and Mazda.
example
sample input 1
Ahura and Mazda have overlapping areas in their marked rectangles. Since they avoid planting in these overlapping areas, the non-overlapping areas for both farmers result in an equal area, making S1−S2=0.
sample output 1
sample input 2
sample output 2
ارسال پاسخ برای این سؤال