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
  1. 2 2
    R1
Output
  1. PRINT 1
    LEFT
    PRINT R
Input
  1. 2 1
    R1
Output
  1. PRINT R
    RIGHT
    PRINT 1
Input
  1. 6 4
    GO?GO!
Output
  1. 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:无脑模拟即可

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef int ll;
  4. inline ll read()
  5. {
  6. ll s=;
  7. bool f=;
  8. char ch=' ';
  9. while(!isdigit(ch))
  10. {
  11. f|=(ch=='-'); ch=getchar();
  12. }
  13. while(isdigit(ch))
  14. {
  15. s=(s<<)+(s<<)+(ch^); ch=getchar();
  16. }
  17. return (f)?(-s):(s);
  18. }
  19. #define R(x) x=read()
  20. inline void write(ll x)
  21. {
  22. if(x<)
  23. {
  24. putchar('-'); x=-x;
  25. }
  26. if(x<)
  27. {
  28. putchar(x+''); return;
  29. }
  30. write(x/);
  31. putchar((x%)+'');
  32. return;
  33. }
  34. #define W(x) write(x),putchar(' ')
  35. #define Wl(x) write(x),putchar('\n')
  36. const int N=;
  37. int n,m;
  38. char S[N];
  39. int main()
  40. {
  41. int i;
  42. R(n); R(m);
  43. scanf("%s",S+);
  44. if(m-<n-m)
  45. {
  46. for(i=;i<m;i++) puts("LEFT");
  47. for(i=;i<n;i++)
  48. {
  49. cout<<"PRINT "; putchar(S[i]); putchar('\n'); puts("RIGHT");
  50. }
  51. cout<<"PRINT "; putchar(S[n]);
  52. }
  53. else
  54. {
  55. for(i=m;i<n;i++) puts("RIGHT");
  56. for(i=n;i>;i--)
  57. {
  58. cout<<"PRINT "; putchar(S[i]); putchar('\n'); puts("LEFT");
  59. }
  60. cout<<"PRINT "; putchar(S[]);
  61. }
  62. return ;
  63. }
  64. /*
  65. Input
  66. 2 2
  67. R1
  68. Output
  69. PRINT 1
  70. LEFT
  71. PRINT R
  72.  
  73. Input
  74. 2 1
  75. R1
  76. Output
  77. PRINT R
  78. RIGHT
  79. PRINT 1
  80.  
  81. Input
  82. 6 4
  83. GO?GO!
  84. Output
  85. RIGHT
  86. RIGHT
  87. PRINT !
  88. LEFT
  89. PRINT O
  90. LEFT
  91. PRINT G
  92. LEFT
  93. PRINT ?
  94. LEFT
  95. PRINT O
  96. LEFT
  97. PRINT G
  98. */

codeforces412A的更多相关文章

随机推荐

  1. EntityFramework学习要点记一

    一.Entity的注解属性(Annotations)不管是code first还是db first,都需要用到注解属性,至于用System.ComponentModel.DataAnnotations ...

  2. 如何调试Python程序 通过IDLE

    在python3.3环境下 1.写一个简单地Python源文件,比如test.py,内容如下: import sys, osdef test(arg1, arg2): print "begi ...

  3. 第十章、sys模块

    目录 第十章.sys模块 第十章.sys模块 方法 详解 sys.argv 命令行参数List,第一个元素是程序本身路径 sys.modules.keys() 返回所有已经导入的模块列表 sys.ex ...

  4. Delphi 画笔

    樊伟胜

  5. 3.NIO_Buffer缓冲区

    1.缓冲区(Buffer) 一个用于特定基本数据类型的容器.由 java.nio 包定义的,所有缓冲区都是 Buffer 抽象类的子类,任何时候访问 NIO 中 的数据,都是通过缓冲区进行操作 在 J ...

  6. Scal(三)——类与对象

    Scala快速入门(三)--类与对象 一.类 这边类的模板如下,和Java很像 object a { def main(args: Array[String]): Unit = { val perso ...

  7. Beta冲刺版本第三天

    该作业所属课程:https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass2 作业要求地址:https://edu.cnblogs.com ...

  8. [工具] fierce--子域收集

    简介 fierce 是使用多种技术来扫描目标主机IP地址和主机名的一个DNS服务器枚举工具.运用递归的方式来工作.它的工作原理是先通过查询本地DNS服务器来查找目标DNS服务器,然后使用目标DNS服务 ...

  9. kotlin面向对象入门

    之前在学kotlin基础语法时咱们是采用三方jar包在eclipse工程下进行的,很显然这工具在实际商用中基本上很少用到了,最终是要编写android程序,所以说从这里起得更换一个更加智能更加贴近实际 ...

  10. 安装Angulr CLI

    参考文档 https://www.jianshu.com/p/327d88284abb http://blog.csdn.net/zhy13087344578/article/details/6074 ...