CF412A.Poster

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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!

R1 公司最近在莫斯科市中心购置了一栋高层建筑作为其总部办公地点。现在是时候装饰新办公室了,而首要任务就是在大楼主入口上方悬挂公司的标语。

该公司的标语由 nn 个字符组成,因此装饰人员悬挂了一幅宽 nn 米、高 11 米的大型横幅,并将其均分为 nn 个相等的方格。标语的第一个字符必须写在横幅的第一个方格(最左侧)中,第二个字符必须写在第二个方格中,依此类推。

当然,R1 公司的程序员希望亲自在横幅上书写标语。为此,他们准备了一架大型(且非常沉重)的梯子,该梯子被精确地放置在横幅第 kk 个方格正前方。要在横幅上绘制标语的第 ii 个字符,画师需攀上梯子并站在横幅第 ii 个方格正前方——这一整套动作(包括攀爬梯子上下)耗时一小时。当梯子位于第 ii 个方格正前方时,画师不允许在相邻方格中绘制字符,因为梯子位置带来的不适感可能导致字符书写不整齐。此外,程序员可以移动梯子:每小时可将梯子向右或向左平移一米。

绘制字符和移动梯子都极为耗费体力,因此程序员希望以尽可能少的时间完成全部工作。请为他们设计一个最优的横幅绘制方案!

输入格式

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: '.', '!', ',', '?'.

第一行包含两个整数 nn 和 kk(1 ≤ k ≤ n ≤ 1001 ≤ k ≤ n ≤ 100),分别表示标语中的字符个数以及梯子的初始位置。
下一行包含该标语,由 nn 个字符组成,字符间无空格。标语中的每个字符均为大写英文字母、数字,或以下字符之一:'.'、'!'、','、'?'。

输出格式

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.

在 t 行中,输出程序员需要执行的操作。第 i 行输出:

  • “LEFT”(不带引号),如果第 i 个操作是“将梯子向左移动”;
  • “RIGHT”(不带引号),如果第 i 个操作是“将梯子向右移动”;
  • “PRINT x”(不带引号),如果第 i 个操作是“爬上梯子,绘制字符 x,再爬下梯子”。

绘图总时间(变量 t)必须为可能的最小值。若存在多种最优绘图方案,可输出其中任意一种。

输入输出样例

  • 输入#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.

注意,梯子的移动距离不能小于一米。梯子只能放置在海报的某个方格正前方。例如,你不能将梯子移动半米并将其置于两个方格之间。然后向上攀爬,并涂画第一个字符和第二个字符。

输入解题思路,AI测评打分。不知道怎么写?

首页