Submission #1129201

#TimeUsernameProblemLanguageResultExecution timeMemory
1129201mnbvcxz123Knjige (COCI20_knjige)C++20
50 / 50
29 ms3072 KiB
#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 timeMemoryGrader output
Fetching results...