Description
给出一个长度为
n
的字符串,初始在
Input
第一行两个整数
n,p
表示字符串长度和起始位置,之后输入一个长度为
n
的字符串,然后输入一个整数
Output
输出经过位置上的字符组成一个长度为 m+1 的字符串
Sample Input
7 1
taconut
10
RRRLRLRRRR
Sample Output
tacococonut
Solution
简单模拟
Code
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f,maxn=100001;
char s[maxn],t[maxn];
int n,m,p;
int main()
{
while(~scanf("%d%d",&n,&p))
{
scanf("%s%d%s",s,&m,t);
printf("%c",s[--p]);
for(int i=0;i<m;i++)
if(t[i]=='R')printf("%c",s[++p]);
else printf("%c",s[--p]);
printf("\n");
}
return 0;
}