302160: CF412A. Poster

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Poster

题意翻译

### 题意简述 某公司要挂一个横幅来写口号。 该公司的口号由n字组成,横幅长n米,宽1米,分割成了n个1* 1的格子(紧挨着排成一行)。口号的第一个字写在第一格,最后一个字写在最后一格,整行格子正好填满。他们有一个梯子,一开始放在第k格上。 要在海报上画标语的第m个字符,你需要爬上梯子,站在海报的第m个正方形前面。 这个动作(连同爬上和爬下梯子)对一个画家来说需要一个小时。 画家只能在正对的格子上绘制。当然梯子可以移动。在一个小时内,他们可以把梯子向右移动一米,或者向左移动一米。 请你规划出耗时最短的画完横幅的方案。 ### 输入格式 输入共两行 第一行:两个整数,n和k,意义如上。(1<=k<=n<=100) 第二行包含没有空格的n字符的口号。 口号的每个字符要么是一个大的英文字母,要么是数字,要么是一个字符:‘。 ‘,’! ‘,’,‘,’? ‘。 ### 输出格式 在每一行中,打印工作人员的操作。 如果向左挪梯子,输出“LEFT”。 同理,向右挪梯子输出“RIGHT”。 如果是上梯子,画字符,再下来,就输出“Print x”,其中“x”表示那个字符。 所有输出后均需换行,均不输出引号。 绘画时间必须是最小的可能。 如果有多个最佳绘画计划,您可以打印其中任何一个。 ### 说明与提示 梯子不能移动非整数的距离(即不能小于1m),您也不能站在两个正方形中间来试图一次性绘制两个字符。

题目描述

The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building. The slogan of the company consists of $ n $ characters, so the decorators hung a large banner, $ n $ meters wide and $ 1 $ meter high, divided into $ n $ equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on. Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the $ k $ -th square of the poster. To draw the $ i $ -th character of the slogan on the poster, you need to climb the ladder, standing in front of the $ i $ -th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the $ i $ -th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left. Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!

输入输出格式

输入格式


The first line contains two integers, $ n $ and $ k $ $ (1<=k<=n<=100) $ — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as $ n $ characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.

输出格式


In $ t $ lines, print the actions the programmers need to make. In the $ i $ -th line print: - "LEFT" (without the quotes), if the $ i $ -th action was "move the ladder to the left"; - "RIGHT" (without the quotes), if the $ i $ -th action was "move the ladder to the right"; - "PRINT $ x $ " (without the quotes), if the $ i $ -th action was to "go up the ladder, paint character $ x $ , go down the ladder". The painting time (variable $ t $ ) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.

输入输出样例

输入样例 #1

2 2
R1

输出样例 #1

PRINT 1
LEFT
PRINT R

输入样例 #2

2 1
R1

输出样例 #2

PRINT R
RIGHT
PRINT 1

输入样例 #3

6 4
GO?GO!

输出样例 #3

RIGHT
RIGHT
PRINT !
LEFT
PRINT O
LEFT
PRINT G
LEFT
PRINT ?
LEFT
PRINT O
LEFT
PRINT G

说明

Note that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.

Input

题意翻译

### 题意简述 某公司要挂一个横幅来写口号。 该公司的口号由n字组成,横幅长n米,宽1米,分割成了n个1* 1的格子(紧挨着排成一行)。口号的第一个字写在第一格,最后一个字写在最后一格,整行格子正好填满。他们有一个梯子,一开始放在第k格上。 要在海报上画标语的第m个字符,你需要爬上梯子,站在海报的第m个正方形前面。 这个动作(连同爬上和爬下梯子)对一个画家来说需要一个小时。 画家只能在正对的格子上绘制。当然梯子可以移动。在一个小时内,他们可以把梯子向右移动一米,或者向左移动一米。 请你规划出耗时最短的画完横幅的方案。 ### 输入格式 输入共两行 第一行:两个整数,n和k,意义如上。(1<=k<=n<=100) 第二行包含没有空格的n字符的口号。 口号的每个字符要么是一个大的英文字母,要么是数字,要么是一个字符:‘。 ‘,’! ‘,’,‘,’? ‘。 ### 输出格式 在每一行中,打印工作人员的操作。 如果向左挪梯子,输出“LEFT”。 同理,向右挪梯子输出“RIGHT”。 如果是上梯子,画字符,再下来,就输出“PRINT x”,其中“x”表示那个字符。 所有输出后均需换行,均不输出引号。 绘画时间必须是最小的可能。 如果有多个最佳绘画计划,您可以打印其中任何一个。 ### 说明与提示 梯子不能移动非整数的距离(即不能小于1m),您也不能站在两个正方形中间来试图一次性绘制两个字符。

加入题单

上一题 下一题 算法标签: