(HDU 1033)Edge

Edge

For products that are wrapped in small packings it is necessary that the sheet of paper containing the directions for use is folded until its size becomes small enough. We assume that a sheet of paper is rectangular and only folded along lines parallel to its initially shorter edge. The act of folding along such a line, however, can be performed in two directions: either the surface on the top of the sheet is brought together, or the surface on its bottom. In both cases the two parts of the rectangle that are separated by the folding line are laid together neatly and we ignore any differences in thickness of the resulting folded sheet.

After several such folding steps have been performed we may unfold the sheet again and take a look at its longer edge holding the sheet so that it appears as a one-dimensional curve, actually a concatenation of line segments. If we move along this curve in a fixed direction we can classify every place where the sheet was folded as either type A meaning a clockwise turn or type V meaning a counter-clockwise turn. Given such a sequence of classifications, produce a drawing of the longer edge of the sheet assuming 90 degree turns at equidistant places.

  • Input

     The input contains several test cases, each on a separate line. Each line contains a nonempty
     string of characters A and V describing the longer edge of the sheet. You may assume that the
     length of the string is less than 200. The input file terminates immediately after the last 
     test case. 
    
  • Output

     For each test case generate a PostScript drawing of the edge with commands placed on separate
     lines. Start every drawing at the coordinates (300, 420) with the command "300 420 moveto".
     The first turn occurs at (310, 420) using the command "310 420 lineto". Continue with
     clockwise or counter-clockwise turns according to the input string, using a sequence of
     "x y lineto" commands with the appropriate coordinates. The turning points are separated at 
     a distance of 10 units. Do not forget the end point of the edge and finish each test case 
     by the commands stroke and showpage. 
     You may display such drawings with the gv PostScript interpreter, optionally after a 
     conversion using the ps2ps utility. 
    

在这里插入图片描述

  • Sample Input

     V
     AVV
    
  • Sample Output

     300 420 moveto
     310 420 lineto
     310 430 lineto
     stroke
     showpage
     300 420 moveto
     310 420 lineto
     310 410 lineto
     20 410 lineto
     320 420 lineto
     stroke
     showpage
    

对于用小包装包装的产品,必须将包含使用说明的纸张折叠,直到其尺寸变得足够小。我们假设一张纸是矩形的,只沿平行于其最初较短边缘的线折叠。然而,沿着这样的线折叠的动作可以在两个方向上进行:纸张顶部的表面或者底部的表面。在两种情况下,由折叠线分开的矩形的两个部分整齐地放置在一起,并且我们忽略所得折叠片材的厚度的任何差异。
在已经执行了几次这样的折叠步骤之后,我们可以再次展开片材并且看一下其保持片材的较长边缘,使得它看起来是一维曲线,实际上是线段的串联。如果我们沿固定方向沿着这条曲线移动,我们可以将每张折叠纸张的地方分类为A型表示顺时针转动或V型表示逆时针转动。给定这样的分类序列,在等距的位置处产生90度转弯的纸张的较长边缘的图。

输入包含几个测试用例,每个测试用例在一个单独的行上。每行包含一个非空字符串A和V,用于描述工作表的较长边。您可以假设字符串的长度小于200.输入文件在最后一个测试用例之后立即终止。

对于每个测试用例,生成边缘的PostScript绘图,并将命令放在单独的行上。使用命令“300 420 moveto”在坐标(300,420)处开始每个绘图。第一次转弯发生在(310,420),使用命令“310 420 lineto”。根据输入字符串继续顺时针或逆时针旋转,使用一系列具有适当坐标的“xy lineto”命令。转折点以10个单位的距离分开。不要忘记边缘的终点,并通过命令stroke和showpage完成每个测试用例。
您可以使用gv PostScript解释器显示此类绘图,可选择在使用ps2ps实用程序进行转换后。

看了好久才看懂,就是从(300, 420)的点开始,最开始往右走,每一步长度为10,A为顺时针转折,V为逆时针转折。也就是说前两个输出固定,模拟一下,然后完成每个样例后都输出stroke和showpage。

在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_44413445/article/details/87949959
hdu