QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 10

#11659. Polygons

الإحصائيات

Yesterday Little John had a test on geometry. The description of the most difficult problem follows. Given two triangles $ A $ and $ B $, calculate the area of region $ A + B $, which is defined as follows: $ A + B = \{p_{1} + p_{2} : p_{1} \in A, p_{2} \in B\}$. For example, if $ A $ has the vertices (0, 0), (0, 2), (2, 0) and $ B $ has the vertices (0, 0), (0, 1), (3, 0), then $ A $ + $ B $ is a polygon with the vertices (0, 0), (0, 3), (3, 2) and (5, 0), so its area is 9.5.

Afterwards, John started to wonder how to solve a modified problem - "How to calculate area of $ A + B $, if $ A $ and $ B $ are arbitrary convex polygons". Little John has a test on biology tomorrow and has no time to solve this problem himself. He asked you for help in solving this task.

Write a program, which:

  • reads the descriptions of two convex polygons $ A $ and $ B $,
  • computes the area of $ A + B $,
  • writes it doubled to the standard output.

Input Format

The first line of the standard input contains two integers $ n $ and $ m $ ($3 ≤ n, m ≤ 100\,000$) separated with a single space and denoting the numbers of vertices of polygons $ A $ and $ B $. In the second line there are $ n $ pairs of integers ($ x_{i} $, $ y_{i} $) ($-100\,000\,000 ≤ x_{i}, y_{i} ≤ 100\,000\,000$), denoting the coordinates of consecutive vertices of the polygon $ A $ (in the clockwise order). In the third line there are $ m $ pairs of integers $(x_i, y_i)$ ($-100\,000\,000 ≤ x_{i}, y_{i} ≤ 100\,000\,000$) denoting the coordinates of consecutive vertices of the polygon $ B $ (in the clockwise order).

Output Format

The first and only line should contain one integer - doubled area of $ A + B $.

Example

Input

4 4
0 0 0 1 2 1 2 0
0 0 0 2 1 2 1 0

Output

18

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.