# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
404039 |
2021-05-13T17:13:19 Z |
ScarletS |
Knjige (COCI20_knjige) |
C++17 |
|
4 ms |
1484 KB |
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
using namespace std;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
bool x;
cin>>n;
int a[n];
stack<int> s,t;
vector<string> ans;
for (int i=0;i<n;++i)
cin>>a[i];
for (int i=n-1;i+1;--i)
s.push(a[i]);
sort(a,a+n,greater<int>());
for (int i=0;i<n;++i)
{
x=0;
while (sz(s)>i)
{
if (s.top()==a[i]&&x==0)
{
ans.push_back("UZMI L L");
x=1;
s.pop();
}
else if (x)
{
ans.push_back("UZMI D L");
ans.push_back("STAVI D D");
t.push(s.top());
s.pop();
}
else
{
ans.push_back("UZMI L L");
ans.push_back("STAVI L D");
t.push(s.top());
s.pop();
}
}
ans.push_back("STAVI L L");
s.push(a[i]);
while (sz(t))
{
ans.push_back("UZMI L D");
ans.push_back("STAVI L L");
s.push(t.top());
t.pop();
}
}
cout<<sz(ans)<<"\n";
for (string i : ans)
cout<<i<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1484 KB |
Output is correct |
2 |
Correct |
4 ms |
1484 KB |
Output is correct |
3 |
Correct |
3 ms |
1484 KB |
Output is correct |
4 |
Correct |
3 ms |
1484 KB |
Output is correct |
5 |
Correct |
4 ms |
1484 KB |
Output is correct |
6 |
Correct |
3 ms |
1484 KB |
Output is correct |
7 |
Correct |
3 ms |
1380 KB |
Output is correct |
8 |
Correct |
3 ms |
1464 KB |
Output is correct |
9 |
Correct |
3 ms |
1468 KB |
Output is correct |
10 |
Correct |
3 ms |
1484 KB |
Output is correct |