luogu#P3559. [POI2013] LAB-Maze
[POI2013] LAB-Maze
题目描述
Note: During the contest, you can ask for the score of three arbitrarily chosen submissions for this problem.
Byteasar read an interesting story recently.
Its protagonist was some Greek crown princewho defeated a monster with a wool yarn,or something like that.
But something else fascinated Byteasar about the story.
What he liked most was the fact that the climax took place in a maze.
From then on Byteasar is crazy about mazes.
Byteasar sketches mazes on a squared sheet of paper.
Each sketch is a polygon with sides (representing the walls of the maze)parallel to either of the sheet's edges (i.e., the axes of the Carthesiancoordinate system), and every two successive sides are perpendicular.
Byteasar observed that if the entrance is placed on one of the sides of sucha maze, then one can traverse the whole maze and return to the entrance byalways keeping the right hand to the wall as one goes.
Moreover, throughout the maze traversal we can note the turns we take.
We shall write the letter L if we turn left when we move alongone wall to another, and P if we turn right in such case.
Byteasar wonders for which words composed of the letters L and Pthere exists a maze whose traversal results in writing this very word.
用L和P描述一个边与坐标轴平行的简单多边形,其中L表示往左拐,P表示往右拐。给定L,P的描述,请输出这个多边形。
输入格式
The first line of the standard input gives a single -letter word()composed of the letters L and P, describingthe sequence of successive turns made during the maze's traversal.
In tests worth 50% of the total points an additional constraint holds.
输出格式
If no maze corresponds to the description given as input,then the word NIE (Polish for no) is to be printedon the standard output.
Otherwise, exactly lines should be printed, specifying any maze(consistent with the input) as follows.
The -th of these lines is to hold two integers, and (), separated by a single space,that are the coordinates of the -th vertex of the maze's sketch.
The vertices are to be printed in their counterclockwise order on the polygon's perimeter;an arbitrary vertex can be chosen as the first one, and the position of the entrance need not be indicated.
LLLLPPLL
0 0
2 0
2 2
-1 2
-1 -2
1 -2
1 -1
0 -1
提示
用L和P描述一个边与坐标轴平行的简单多边形,其中L表示往左拐,P表示往右拐。给定L,P的描述,请输出这个多边形。