# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
377832 | kshitij_sodani | Knjige (COCI20_knjige) | C++14 | 3 ms | 492 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.
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl '\n'
int it[101];
int n;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
vector<int> ss;
for(int i=0;i<n;i++){
cin>>it[i];
ss.pb(it[i]);
}
sort(ss.begin(),ss.end());
int ans=0;
for(int i=0;i<n;i++){
ans+=2;
ans+=4*(n-i-1);
}
//reverse(ss.begin(),ss.end());
for(int i=0;i<n/2;i++){
swap(it[i],it[n-i-1]);
}
cout<<ans<<endl;
for(int i=0;i<n;i++){
int x=ss[n-i-1];
int st=0;
for(int j=n-1;j>=i;j--){
if(st==0){
if(it[j]==x){
st=j+1;
}
}
}
st--;
vector<int> tt;
for(int j=i;j<n;j++){
if(j!=st){
tt.pb(it[j]);
// cout<<it[j]<<",";
}
}
// cout<<endl;
it[i]=ss[n-i-1];
for(int k=0;k<tt.size();k++){
it[i+k+1]=tt[k];
}
/*for(int j=0;j<n;j++){
cout<<it[j]<<":";
}
cout<<endl;*/
for(int j=n-1;j>=i;j--){
if(j==st){
cout<<"UZMI D L"<<endl;
}
else{
cout<<"UZMI L L"<<endl;
cout<<"STAVI L D"<<endl;
}
}
cout<<"STAVI D L"<<endl;
for(int j=n-1;j>=i;j--){
if(j==st){
}
else{
cout<<"UZMI L D"<<endl;
cout<<"STAVI L L"<<endl;
}
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |