# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
445944 | Jasiekstrz | Knjige (COCI20_knjige) | C++17 | 5 ms | 1484 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 fi first
#define se second
using namespace std;
const int N=1e5;
int h[2]={-1,-1};
vector<int> st[2];
vector<string> ans;
void take(bool hand,bool shelf)
{
h[hand]=st[shelf].back();
st[shelf].pop_back();
ans.push_back((string)"UZMI "+(hand ? "D":"L")+" "+(shelf ? "D":"L"));
return;
}
void put(bool hand,bool shelf)
{
st[shelf].push_back(h[hand]);
h[hand]=-1;
ans.push_back((string)"STAVI "+(hand ? "D":"L")+" "+(shelf ? "D":"L"));
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
st[0].resize(n);
for(int i=1;i<=n;i++)
cin>>st[0][n-i];
while(!st[0].empty())
{
take(0,0);
put(0,1);
}
for(int i=0;i<n;i++)
{
take(0,1);
while(!st[1].empty())
{
if(st[1].back()>h[0])
{
put(0,0);
take(0,1);
}
else
{
take(1,1);
put(1,0);
}
}
while(st[0].size()>i)
{
take(1,0);
put(1,1);
}
put(0,0);
}
cout<<ans.size()<<"\n";
for(auto v:ans)
cout<<v<<"\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |