# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
395450 | MrRobot_28 | Knjige (COCI20_knjige) | C++17 | 3 ms | 976 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;
#define X first
#define Y second
#define sz(a) (int)a.size()
#define ll long long
#define ld long double
signed main()
{
//ifstream cin("286.txt");
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector <int> d(n);
for(int i = 0; i < n; i++)
{
cin >> d[i];
}
vector <string> ans;
vector <int> mass;
for(int i = 0; i < n; i++)
{
ans.push_back("UZMI L L");
int cnt = 0;
vector <int> t;
while(sz(mass) > 0 && mass.back() > d[i])
{
cnt++;
ans.push_back("UZMI D D");
t.push_back(mass.back());
ans.push_back("STAVI D L");
mass.pop_back();
}
ans.push_back("STAVI L D");
mass.push_back(d[i]);
while(cnt--)
{
mass.push_back(t.back());
t.pop_back();
ans.push_back("UZMI D L");
ans.push_back("STAVI D D");
}
}
while(n--)
{
ans.push_back("UZMI D D");
ans.push_back("STAVI D L");
}
cout << sz(ans) << "\n";
for(auto s : ans)
cout << s << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |