Pentagon
Time limit2sMemory limit1024 MB
Given up to 10,000 pentagons by their vertex coordinates, count the triangulations of each one, where every pentagon has 5 possible diagonal sets with at most 5 triangulations per shape.
- Level
Easy3 of 10
- Topics
- Geometry, Dynamic programming
- Solved
- No attempts yet
Statement
You are given a pentagon. Find the number of its triangulations.
A triangulation of polygon is a collection of triangles such that the internal areas of these triangles have no common points, and their union is equal to . Each vertex of each triangle must coincide with some vertex of the polygon. Each side of each triangle must either fully coincide with some side of the polygon or have exactly two common points (endpoints) with the border of the polygon.
Input
The first line contains one integer , the number of test cases (). Each test case is preceded by a single empty line.
Each test case describes one pentagon and consists of five lines. Each line contains two integers and separated by a single space: the coordinates of the next vertex of the pentagon, listed in clockwise or counter-clockwise order (). Every pentagon has no self-intersections and no self-touchings. No two adjacent sides of the polygon lie on the same line.
Output
Print lines, one for each test case. Each line contains one integer: the number of different triangulations of the corresponding pentagon.
Hint
The figure below shows all possible triangulations of the first pentagon in the example.
