Poster

CodeForces - 412A

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

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

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的更多相关文章

随机推荐

  1. Java EE javax.servlet.http中的HttpSession接口

    HttpSession接口 public interface HttpSession (https://docs.oracle.com/javaee/7/api/javax/servlet/http/ ...

  2. 【原创】大叔经验分享(64)cloudera manager agent启动组件进程过程

    概述 The Agent is started by init.d at start-up. It, in turn, contacts the Cloudera Manager Server and ...

  3. 对MySQL索引、锁及事务的简单分析

    一.索引的数据结构 1.二叉搜索树实现的索引 二叉搜索树如下图,它查找元素的时间复杂度为O(logn) 但如果经常出现增删操作,最后导致二叉搜索树变成线性的二叉树,这样它查找元素的时间复杂度就会变成O ...

  4. C++typedef struct和struct的区别

    #include "pch.h" #include struct struct1 { int a; char b; char* c; }test1;//定义结构体变量 typede ...

  5. 设置本地cookie 存session 保持长期有效

    <?php session_start(); // 启动Session $_SESSION['count']; // 注册Session变量Count isset($PHPSESSID)?ses ...

  6. 内核模式构造-Mutex构造(RecursiveAutoResetEvent)

    internal sealed class RecursiveAutoResetEvent : IDisposable { private AutoResetEvent m_lock = new Au ...

  7. C#微信公众平台账号开发真正给初学者的文章

    微信越来越受到大众人群的喜爱,但是对于开发人员来说刚接触肯能还是一头雾水的,比如像我,看了三四天文档感觉要吐,但是程序还是要写知识还是要学.发现了一个比较适合初学者的文章送给大家,废话到此:(转贴吧) ...

  8. Python中关于csv的简单操作

    Python中关于csv的简单操作 CSV操作简单,直接import csv即可, 主要使用reader和pandas 1 reader的简单使用 csv.reader("1.csv&quo ...

  9. Token认证的优势与劣势

    token 我们说的token,是指 访问资源的凭据 .使用基于 Token 的身份验证方法,在服务端不需要存储用户的登录记录. 大致流程: 客户端使用用户名跟密码请求登录服务端收到请求,验证用户名与 ...

  10. No valid Maven installation found. Either set the home directory in the configuration dialog or set

    原因: IDEA的maven地址设置出错,系统找不到指定的maven路径 解决: setting---->maven修改正确的maven链接地址. 设置你maven 的地址为你的存放路基就好了