# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
452010 | Apiram | Knjige (COCI20_knjige) | C++14 | 36 ms | 2004 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;
vector<string>ans;
vector<char>a,b;
void add(int i,int j,int l){
if (i==0){
ans.push_back("UZMI");
}
else{
ans.push_back("STAVI");
}
if(j==0){
a.push_back('L');
}
else{
a.push_back('D');
}
if (l==0){
b.push_back('L');
}
else{
b.push_back('D');
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;cin>>n;
vector<int>arr(n);
stack<int>first,second;
for (int i = 0;i<n;++i){
cin>>arr[i];
first.push(arr[i]);
}
vector<int>brr=arr;
sort(brr.rbegin(),brr.rend());
int j =0;
bool lefthand=false,righthand=false;
for (int i = 0;i<n;++i){
while(first.top()>brr[i]){
add(0,0,0);
add(1,0,1);
second.push(first.top());
first.pop();
}
add(0,1,0);
int k = first.size();
k-=i;
while(k--){
add(0,0,0);
add(1,0,1);
second.push(first.top());
first.pop();
}
add(1,1,0);
while(!second.empty()){
add(0,0,1);
add(1,0,0);
first.push(second.top());
second.pop();
}
}
cout<<ans.size()<<endl;
for (int i = 0;i<ans.size();++i){
cout<<ans[i]<<" "<<a[i]<<" "<<b[i]<<endl;
}
return 0;}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |