# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1006558 | vjudge1 | Knjige (COCI20_knjige) | C++17 | 28 ms | 3268 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
int main()
{
int n,x;
cin>>n;
vector<int> a,alias;
for (int i=0;i<n;i++)
{
cin>>x;
a.push_back(x);
}
vector<vector<string>> ans;
alias=a;
sort(all(alias),greater<int>());
reverse(all(a));
for (int i=0;i<n;i++)
{
bool b=1;
for (int j=n-1;j>=i;j--)
{
if (a[j]==alias[i] && b)
{
ans.push_back({"UZMI","D","L"});
b=0;
}
else
{
ans.push_back({"UZMI","L","L"});
ans.push_back({"STAVI","L","D"});
}
}
ans.push_back({"STAVI","D","L"});
b=0;
for (int j=n-1;j>i;j--)
{
if (alias[i]==a[j])
b=1;
ans.push_back({"UZMI","L","D"});
ans.push_back({"STAVI","L","L"});
if (b)
swap(a[j],a[j-1]);
}
}
cout<<ans.size()<<endl;
for (auto i:ans)
cout<<i[0]<<' '<<i[1]<<' '<<i[2]<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |