codeforces412A
Poster
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!
Input
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: '.', '!', ',', '?'.
Output
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.
Examples
2 2
R1
PRINT 1
LEFT
PRINT R
2 1
R1
PRINT R
RIGHT
PRINT 1
6 4
GO?GO!
RIGHT
RIGHT
PRINT !
LEFT
PRINT O
LEFT
PRINT G
LEFT
PRINT ?
LEFT
PRINT O
LEFT
PRINT G
Note
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.
sol:无脑模拟即可
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=;
int n,m;
char S[N];
int main()
{
int i;
R(n); R(m);
scanf("%s",S+);
if(m-<n-m)
{
for(i=;i<m;i++) puts("LEFT");
for(i=;i<n;i++)
{
cout<<"PRINT "; putchar(S[i]); putchar('\n'); puts("RIGHT");
}
cout<<"PRINT "; putchar(S[n]);
}
else
{
for(i=m;i<n;i++) puts("RIGHT");
for(i=n;i>;i--)
{
cout<<"PRINT "; putchar(S[i]); putchar('\n'); puts("LEFT");
}
cout<<"PRINT "; putchar(S[]);
}
return ;
}
/*
Input
2 2
R1
Output
PRINT 1
LEFT
PRINT R Input
2 1
R1
Output
PRINT R
RIGHT
PRINT 1 Input
6 4
GO?GO!
Output
RIGHT
RIGHT
PRINT !
LEFT
PRINT O
LEFT
PRINT G
LEFT
PRINT ?
LEFT
PRINT O
LEFT
PRINT G
*/
codeforces412A的更多相关文章
随机推荐
- WPF的硬件加速
wpf根据硬件 可以做出三档的渲染 dx7以下 第0档 不支持硬件加速 dx7-dx9 第1档, 不支持所有硬件加速,但支持一部分 dx9 以上 支持所有硬件加速 可以用编程的方式取代 当前设备处于 ...
- WAV格式文件无损合并&帧头数据体解析(python)(原创)
一,百度百科 WAV为微软公司(Microsoft)开发的一种声音文件格式,它符合RIFF(Resource Interchange File Format)文件规范,用于保存Windows平台的音频 ...
- QT 获取字体大小
QFont font(androidFont); QFontInfo fInfo(font); qDebug()<<"FFFFFFFFFFFFFFFFFFFFFFFPPPSIZE ...
- Boost Graph Library materials
Needed to compute max flow in a project and found the official document of BGL to be rather obscure, ...
- postgresql与mysql 优缺点
MySQL的主要优点 (速度,流行,window,线程,事务) 1. 首先是速度,MySQL通常要比PostgreSQL快得多.MySQL自已也宣称速度是他们追求的主要目标之一,基于这个原因,MySQ ...
- 4.Struts2-OGNL
/*ognl 是 strut2 特有的表达式,使用 ognl,struts2 就无需将对象手动放值进request等范围,页面(从值栈中)直接传值*/ OGNL <?xml version=&q ...
- frp 路由穿透(github开源穿透软件)
server配置(windows):下载: https://github.com/fatedier/frp/releases [common] # 服务器端端口 bind_port = # 客户端连接 ...
- C++ void*解惑
最近遇到void *的问题无法解决,发现再也无法逃避了(以前都是采取悄悄绕过原则),于是我决定直面它. 在哪遇到了? 线程创建函数pthread_create()的最后一个参数void *arg,嗯? ...
- bom and dom
bom:Broswer Object Model: 浏览器对象模型- navigator: 获取客户机的信息(浏览器的信息)document.write(navigator.appName);- sc ...
- Pysnooper 一款大受欢迎的Debug模块
Github地址 安装 PIP pip install pysnooper import pysnooper @pysnooper.snoop() def number_to_bits(number) ...