Home > Back-end >  Which programming bosses help have a look
Which programming bosses help have a look

Time:09-18

Problem description
For a polygon, if can replicate by itself many times to not heavy cover without skipping an infinite two-dimensional plane, we call this polygon can bespread plane, figure 1 shows a L shape polygons, figure 2 shows how it spread not heavy don't leak full plane, you need to write a program to determine whether the given polygon can bespread plane,

Each set of test data is composed of a closed polygon, the polygons all Angle for right Angle, the length of each edge are integer times of unit length, you can copy the polygon at random, can also move them on the plane, but it can't rotate or flip an arbitrary polygon,

The following are some of the information may be useful:
There are only two essentially different covered plane: using quadrilateral is paved with plane covered (board), or the use of hexagonal covered plane covered (hives), a polygon if and only if the following two conditions: when at least one can bespread plane in
1. In the progressive exist on the four points A, B, C, D (do not have to be A polygon vertices), make the boundary of A to B and D to the border of C, B to C the boundary of the border with A to D overlap, this suggests that the polygon can be covered by cover board plane,
2. In the progressive exist on the six points A, B, C, D, E, F (not necessarily polygon vertices), make the boundary of A to B and E to D boundary, the boundary of the B to C to E and F the boundary of the overlap, C to D boundary and the boundary of A to F, suggesting that the polygon can be covered in honeycomb covered way plane,
Input format
The input contains description of several polygons, each row represents a polygon is questioned,
Each line begins with an integer n, said several of the side of the polygon, the following description in anticlockwise order each side, each description is a letter followed by a number, the letter is "n", "E", "S" or "W", said the direction of the line segment respectively north, east, south or west, digital said the line length is how many units, guarantee the polygon fellowship with their own connections or not,
Input end with a single line of "0",
The output format
For each polygon, the output of a line,
Output polygon number first, then can be covered if the polygon plane, then output "Possible", can not covered if the polygon plane, then output "Impossible", specific see sample output format,
The sample input
3 W 6 N 1 S 4 E 4 N 1 W 3
8 E 5 N 1 W 3 4 S 5 N 3 2 N E 1 W
0
Sample output
Polygon 1: Possible
Polygon 2: Impossible
The data size and agreed
30% of the data, n 20 or less, polygon circumference 20 or less
100% of the data, n, 50 or less polygons circumference 50 or less, in each test data is not more than 50 polygon,
  • Related