#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N=5e5+5;
int const mod=1e9+7;
int main(){
int n;
cin>>n;
stack<int> lst,rst;
for(int i=0;i<n;i++){
int a;
cin>>a;
lst.push(a);
}
vector<string> move;
for(int i=0;i<n;i++){
int rh=-1;
while(lst.size()>0){
if(rh==-1){
//take the book on top of left in your rh
move.push_back("UZMI R L");
rh=lst.top();
lst.pop();
}
else if(rh<lst.top()){
//put rh book on top of right.
move.push_back("STAVI R R");
rst.push(rh);
//take the book from top of left in your rh
move.push_back("UZMI R L");
rh=lst.top();
lst.pop();
}
else{
rst.push(lst.top());
//take the book from top of left in your lh
move.push_back("UZMI L L");
lst.pop();
//put lh book on top of right.
move.push_back("STAVI L R");
}
}
//place book in your rh on top of left
move.push_back("STAVI R L");
lst.push(rh);
while(!rst.empty()){
lst.push(rst.top());
//take book in your lh from top of right
move.push_back("UZMI L R");
rst.pop();
//place book in your lh on top of left.
move.push_back("STAVI L L");
}
}
cout<<move.size()<<endl;
for (string s:move)
cout<<s<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
43 ms |
2512 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
2 |
Incorrect |
41 ms |
2512 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
3 |
Incorrect |
35 ms |
2512 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
4 |
Incorrect |
41 ms |
2508 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
5 |
Incorrect |
36 ms |
2512 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
6 |
Incorrect |
41 ms |
2508 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
7 |
Incorrect |
38 ms |
2764 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
8 |
Incorrect |
40 ms |
2512 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
9 |
Incorrect |
41 ms |
2512 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
10 |
Incorrect |
41 ms |
2512 KB |
Token "R" doesn't correspond to pattern "(L|D)" |