#include<bits/stdc++.h>
using namespace std;
signed main(){
ios::sync_with_stdio(false);cin.tie(0);
int n; cin >> n;
vector<int> L(n);
vector<int> R;
for(int i = 0;i < n;i++) cin >> L[i];
vector<pair<int,int> > bruh;
for(int i = 0;i < n;i++) bruh.push_back({L[i], i});
sort(bruh.begin(), bruh.end());
for(int i = 0;i < n;i++){
L[bruh[i].second] = i+1;
}
reverse(L.begin(),L.end());
vector<string> ans;
for(int iter = n;iter >= 2;iter--){
for(int i = 0;i < iter;i++){
if(L.back() == iter){
ans.push_back("UZMI D L\n");
}
else{
ans.push_back("UZMI L L\n");
ans.push_back("STAVI L D\n");
R.push_back(L.back());
}
L.pop_back();
}
ans.push_back("STAVI D L\n");
L.push_back(iter);
while(not R.empty()){
ans.push_back("UZMI L D\n");
ans.push_back("STAVI L L\n");
L.push_back(R.back());
R.pop_back();
}
}
cout << (int) ans.size() << '\n';
for(string s : ans) cout << s;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1348 KB |
Output is correct |
2 |
Correct |
2 ms |
1460 KB |
Output is correct |
3 |
Correct |
2 ms |
1484 KB |
Output is correct |
4 |
Correct |
2 ms |
1484 KB |
Output is correct |
5 |
Correct |
2 ms |
1484 KB |
Output is correct |
6 |
Correct |
2 ms |
1404 KB |
Output is correct |
7 |
Correct |
2 ms |
1484 KB |
Output is correct |
8 |
Correct |
2 ms |
1484 KB |
Output is correct |
9 |
Correct |
2 ms |
1484 KB |
Output is correct |
10 |
Correct |
2 ms |
1484 KB |
Output is correct |