Pro.ID10242 TitleEther Geometry Title链接http://10.20.2.8/oj/exercise/problem?problem_id=10242 AC0 Submit0 Ratio- 时间&空间限制描述Euclid, dwelt in Alexandria, still being convinced farmly that there is no Royal Road to Euclidean Geometry yet, began to feel gradually, reading newspaper articles, watching TV programs, or brainwashed by young students, that it might be possible to create such a discipline as e-Geometry or Geometry on the Internet. In an e-Geometry environment, he could timely discuss geometry issues with many friends of his including Pythagoras, or he could upload new versions of his unparalleled famous archive "Elements of Geometry (Stoicheia)" on his WWW site. He He started laying ether cable himself from the hub to his terminal in his uniquely shaped study. He designed the cable route as short as possible. Figure 1 is a plan of his study. Integers in a pair of parentheses like (0 0) are x- and y-coordinates of the nearest pillar or hub or terminal. Between two adjacent pillars are walls indicated by the solid lines. Suppose A is the position of the hub and B his terminal, then the shortest cable may run as drawn with a broken line. Your mission is to answer the sequence of the coordinates of turning points of the shortest cable route including those of both ends A and B for each plan. So, you are to answer as: (1 1) (2 2) (8 4) (9 5) for the example of Figure 1. Remember, however, that this is a house of Euclid, the founder and master of Euclidean Geometry. The pillars, hub and terminal are ideal points of Euclidean Geometry. The walls and cable are line segments in the sense of geometry. Accordingly, the cable may overlap the walls or the pillars. Hence for Figures 2, 3 and 4, the answers should be as follows:(Hereafter, the layouts of the study are given by means of the lists of the pillar coordinates.) Figure 2: Pillars: (0 0) (2 0) (2 2) (4 2) (4 0) (6 0) (6 6) (4 6) (4 4) (2 4) (2 6) (0 6) Figure 3: Pillars: Figure 4: Pillars: All values of coordinates are integers. Walls are parallel to either x- or y-axis. Walls turn right or left at each pillar for which the coordinates are given. The coordinates of the pillars are given in the order to look the inside of study to the left. From the last pillar in the list, the next wall stretches to the first pillar. Every position of the pillar appears only once in the list. Each pillar is connected to exactly two walls, one of which is parallel to x-axis and the other to y-axis. The whole wall surrounds the study with single stroke closing line. No walls cross. No wall branches exist. It is known that no independent walls or other obstacles are found inside the study. Only one hub and one terminal exist inside the study for each plan, and their positions are always different. Submit your program when it could solve for the study of complicated shape like Figure 5. This layout is included in the sample input. Pillars: 输入The input contains one or more data sets of the coordinates of the pillars, hubs and terminals. Each set begins with a line of an integer n (4 ≤ n ≤ 208), which is the number of the pillars of the study. The following lines contain the coordinates of pillars, five pairs of coordinates per line. After these lines comes one line that contains the coordinates of the hub (ax ay) and the terminal (bx by). The structure of one complete data set is as follows: (Input/output data do not use parentheses.) n To make the situation simple, the coordinates of the pillars are all even integers, while those of the hub and terminal are all odd. It is also known that the room size is less than 100 coordinate units in both x and y directions and the cable length is shorter than 1000 coordinate units. The input is terminated by a line having one 0 after the last set. 输出Description Euclid, dwelt in Alexandria, still being convinced farmly that there is no Royal Road to Euclidean Geometry yet, began to feel gradually, reading newspaper articles, watching TV programs, or brainwashed by young students, that it might be possible to create such a discipline as e-Geometry or Geometry on the Internet. In an e-Geometry environment, he could timely discuss geometry issues with many friends of his including Pythagoras, or he could upload new versions of his unparalleled famous archive "Elements of Geometry (Stoicheia)" on his WWW site. He He started laying ether cable himself from the hub to his terminal in his uniquely shaped study. He designed the cable route as short as possible. Figure 1 is a plan of his study. Integers in a pair of parentheses like (0 0) are x- and y-coordinates of the nearest pillar or hub or terminal. Between two adjacent pillars are walls indicated by the solid lines. Suppose A is the position of the hub and B his terminal, then the shortest cable may run as drawn with a broken line. Your mission is to answer the sequence of the coordinates of turning points of the shortest cable route including those of both ends A and B for each plan. So, you are to answer as: (1 1) (2 2) (8 4) (9 5) for the example of Figure 1. Remember, however, that this is a house of Euclid, the founder and master of Euclidean Geometry. The pillars, hub and terminal are ideal points of Euclidean Geometry. The walls and cable are line segments in the sense of geometry. Accordingly, the cable may overlap the walls or the pillars. Hence for Figures 2, 3 and 4, the answers should be as follows:(Hereafter, the layouts of the study are given by means of the lists of the pillar coordinates.) Figure 2: Pillars: (0 0) (2 0) (2 2) (4 2) (4 0) (6 0) (6 6) (4 6) (4 4) (2 4) (2 6) (0 6) Figure 3: Pillars: Figure 4: Pillars: All values of coordinates are integers. Walls are parallel to either x- or y-axis. Walls turn right or left at each pillar for which the coordinates are given. The coordinates of the pillars are given in the order to look the inside of study to the left. From the last pillar in the list, the next wall stretches to the first pillar. Every position of the pillar appears only once in the list. Each pillar is connected to exactly two walls, one of which is parallel to x-axis and the other to y-axis. The whole wall surrounds the study with single stroke closing line. No walls cross. No wall branches exist. It is known that no independent walls or other obstacles are found inside the study. Only one hub and one terminal exist inside the study for each plan, and their positions are always different. Submit your program when it could solve for the study of complicated shape like Figure 5. This layout is included in the sample input. Pillars: Input The input contains one or more data sets of the coordinates of the pillars, hubs and terminals. Each set begins with a line of an integer n (4 ≤ n ≤ 208), which is the number of the pillars of the study. The following lines contain the coordinates of pillars, five pairs of coordinates per line. After these lines comes one line that contains the coordinates of the hub (ax ay) and the terminal (bx by). The structure of one complete data set is as follows: (Input/output data do not use parentheses.) n To make the situation simple, the coordinates of the pillars are all even integers, while those of the hub and terminal are all odd. It is also known that the room size is less than 100 coordinate units in both x and y directions and the cable length is shorter than 1000 coordinate units. The input is terminated by a line having one 0 after the last set. Output For each data set, print the sequence of the coordinates of turning points of the shortest cable with those of the hub at the beginning and those of the terminal at the end. Each line should contain five pairs of coordinates separated by a single space, except the last of these lines which may contain fewer than five. In each coordinate pair, x and y values should be separated also by a single space. The last coordinate of each line may be followed by a single space. The answer of each data set must be followed by a single empty line. Sample Input 20 Sample Output 1 1 2 2 8 4 9 5 Source 样例输入20 样例输出1 1 2 2 8 4 9 5 作者 |