# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1104187 | melody_rules | Knjige (COCI20_knjige) | C++17 | 20 ms | 972 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>
#define int long long
using namespace std;
signed main() {
int n=0;
int m=0;
int a=0;
int b=0;
int i=0;
int j=0;
string s;
cin>>n;
vector<int> vec(n);
vector<int> vecoo(n);
vector<string> fin;
for(i=0;i<n;i++) {
cin>>a;
vec.at(i) = a;
vecoo.at(i) = a;
}
sort(vecoo.begin(), vecoo.end());
while(j < (n-1)) {
m = vec.size();
for(i=0;i<m;i++) {
if(vec.at(i) == vecoo.at(j))
break;
s = "UZMI L L";
fin.push_back(s);
s = "STAVI L D";
fin.push_back(s);
}
s = "UZMI D L";
fin.push_back(s);
vec.erase(vec.begin() + i);
a=i;
for(;i>0;i--) {
s = "UZMI L D";
fin.push_back(s);
s = "STAVI L L";
fin.push_back(s);
}
s = "STAVI D D";
fin.push_back(s);
j++;
}
cout<<fin.size() + 2*n - 2<<endl;
for(auto x : fin)
cout<<x<<endl;
for(i=0;i<(n-1);i++) {
cout<<"UZMI L D"<<endl;
cout<<"STAVI L L"<<endl;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |