# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
615399 | ak2006 | Knjige (COCI20_knjige) | C++14 | 29 ms | 1448 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<string>ans;
void f(vector<int> a,int n)
{
if (n <= 1)return;
int mx = 0,pos = 0;
for (int i = 0;i<n;i++){
if (a[i] > mx)pos = i;
mx = max(mx,a[i]);
}
for (int i = 0;i<pos;i++){
//move from left shelf to hand = UZMI L L
//move from hand to right shelf = STAVI L D
ans.push_back("UZMI L L");
ans.push_back("STAVI L D");
}
ans.push_back("UZMI D L");
for (int i = pos + 1;i<n;i++){
//move from left shelf to left hand = UZMI L L
//move from left hand to right shelf = STAVI L D
ans.push_back("UZMI L L");
ans.push_back("STAVI L D");
}
ans.push_back("STAVI D L");
for (int i = 0;i<n - 1;i++){
//move from right shelf to left hand = UZMI D L
//move from left hand to left shelf = STAVI L L
ans.push_back("UZMI L D");
ans.push_back("STAVI L L");
}
vector<int> nxt;
for (int i = 0;i<n;i++){
if (pos == i)continue;
nxt.push_back(a[i]);
}
f(nxt,n - 1);
}
int main()
{
int n;
cin>>n;
vector<int> a(n);
for (int i = 0;i<n;i++)cin>>a[i];
f(a,n);
cout<<ans.size()<<endl;
for (auto it:ans)cout<<it<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |