模拟 Coder-Strike 2014 - Round 1 A. Poster

 

题目地址:http://codeforces.com/problemset/problem/412/A

 1 /*  2  模拟:题目没看懂,但操作很简单,从最近的一头(如果不在一端要先移动到一端)往另一头移动,顺便打印内容  3 */  4 #include <cstdio>  5 #include <iostream>  6 #include <algorithm>  7 #include <cmath>  8 #include <cstring>  9 #include <string> 10 #include <map> 11 using namespace std; 12 13 const int MAXN = 100 + 10; 14 const int INF = 0x3f3f3f3f; 15 char s[MAXN]; 16 17 int main(void) //Coder-Strike 2014 - Round 1 A. Poster 18 { 19 //freopen ("E.in", "r", stdin); 20 21 int n, k; 22 while (~scanf ("%d%d", &n, &k)) 23  { 24 scanf ("%s", &s); 25 int pos; int flag; 26 27 if (k <= (n) / 2) 28  { 29 pos = k - 1; flag = 0; 30  } 31 else 32  { 33 pos = n - k; flag = 1; 34  } 35 36 while (pos--) (flag) ? puts ("RIGHT") : puts ("LEFT"); 37 38 if (flag == 1) 39  { 40 for (int i=n-1; i>=0; --i) 41  { 42 printf ("PRINT "); 43 printf ("%c\n", s[i]); 44 if (i > 0) puts ("LEFT"); 45  } 46  } 47 else 48  { 49 for (int i=0; i<n; ++i) 50  { 51 printf ("PRINT "); 52 printf ("%c\n", s[i]); 53 if (i < n - 1) puts ("RIGHT"); 54  } 55  } 56  } 57 58 return 0; 59 }

 

你可能感兴趣的:(round)