译自 BalticOI 2011 Day2 T3「Polygon」
在平面直角网格图中有一个简单多边形,它有 $N$ 个顶点,每个顶点都在格点上(格点=整点)。
试求:严格在多边形内部的网格线有多长。在「样例解释」中, 严格在多边形内部的网格线将会加粗显示。
请注意精度。设你的答案为 $L$,标准答案为 $R$,则只需满足 $|L − R| ≤ R \times 10^{−6}$ 和 $|L − R| ≤ 10^{−6}$ 两个条件中的其中一个即可得分。
A simple polygon with N vertices is drawn on an infinite rectangular grid. For such a polygon, only neighboring edges touch at their common vertex; no other of its edges intersect or touch. All vertices of the polygon lie on grid points, i.e., vertices have integer coordinates.
Your task is to find the total length of grid line segments which lie strictly inside the given polygon (these line segments are highlighted in the drawings below).