A9416 | Poster
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 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.
- "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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted