当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6654:Intersection of Prisms

题目描述
Cuber QQ used to encounter such a problem: find the intersection of two infinitely long convex right prisms $A$ and $B$. Actually this problem is also on HDU Online Judge, you can solve it afterwards if you are interested.

Cuber QQ quickly solved it, and thought it too easy because his program can handle more than that. So he modify it a little bit, by removing the constraints of ``convex'', that is, the cross-section of these two prisms are not necessarily convex, but they are still simple.

Formally, you have to find the volume of intersection of two prisms, whose cross-sections are both simple polygons. All joining edges of $A$ are parallel to the $z$-axis, and all joining edges of $B$ are parallel to the $x$-axis. If A and B do not intersect, the answer is $0$ of course.
输入解释
The first line is an integer $t$, denoting the number of test cases follows.

For each test case, there are two polygons, the base polygon of $A$ and $B$ respectively.

An integer $n$ ($3 \le n \le 10^5$) followed by $n$ lines, each containing two space-separated integers $(x, y)$ ($-10^6 \le x, y \le 10^6$), is the representation of the base polygon of $A$. The following $m+1$ ($3 \le m \le 10^5$) gives a similar representation for $B$, except that the coordinates given are $(y, z)$ ($-10^6 \le x, y \le 10^6$).

Each polygon are given in either clockwise or counterclockwise order. Following the convention, polygon $P$ is simple, if no two edges have any points in common, with the obvious exception of two consecutive segments having one common point.

The sum of $m+n$ from all test cases does not exceed $2 \cdot 10^6$.
输出解释
For each test case, output the answer modulo $10^9+7$, that is, if the answer is $\frac{P}{Q}$, you should output $P \cdot Q^{-1}$ modulo $10^9+7$, where $Q^{-1}$ denotes the multiplicative inverse of $Q$ modulo $10^9+7$.
输入样例
1
4
10 0
0 10
-10 0
0 -10
3
5 0
-15 -10
-15 10
输出样例
666667713

提示
The intersection of the sample input is 3125/3.

Prisms before intersection:


The intersection part looks like this:
The input size is quite large. Please mind the efficiency of your input buffer.
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6654

最后修改于 2020-10-25T23:33:11+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
14000/7000MS(Java/Others) 524288/524288K(Java/Others)