# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
615399 |
2022-07-31T08:58:00 Z |
ak2006 |
Knjige (COCI20_knjige) |
C++14 |
|
29 ms |
1448 KB |
#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 |
1 |
Correct |
28 ms |
1356 KB |
Output is correct |
2 |
Correct |
29 ms |
1356 KB |
Output is correct |
3 |
Correct |
25 ms |
1356 KB |
Output is correct |
4 |
Correct |
24 ms |
1364 KB |
Output is correct |
5 |
Correct |
27 ms |
1356 KB |
Output is correct |
6 |
Correct |
26 ms |
1356 KB |
Output is correct |
7 |
Correct |
24 ms |
1356 KB |
Output is correct |
8 |
Correct |
24 ms |
1356 KB |
Output is correct |
9 |
Correct |
24 ms |
1356 KB |
Output is correct |
10 |
Correct |
28 ms |
1448 KB |
Output is correct |