您的位置:首页 > 其它

Coder-Strike 2014 - Round 1 A. Poster

2014-04-19 12:28 239 查看
主要就是先将梯子移动到最左边或者最右边

k>n/2时移动到最右边

k<=n/2时移动到最左边

然后遍历一遍

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
int n,k;
cin >> n >> k;
string poster ;
cin >> poster;
if(k > n/2){
for(int i = k-1 ; i < n-1; ++ i){
cout<<"RIGHT"<<endl;
}
for(int i = n-1; i > 0; --i){
cout<<"PRINT "<<poster[i]<<endl;
cout<<"LEFT"<<endl;
}
cout<<"PRINT "<<poster[0]<<endl;
}else{
for(int i = k-1; i>0; --i) cout<<"LEFT"<<endl;
for(int i = 0; i < n-1; ++i){
cout<<"PRINT "<<poster[i]<<endl;
cout<<"RIGHT"<<endl;
}
cout<<"PRINT "<<poster[n-1]<<endl;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: