# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
366277 | model_code | Knjige (COCI20_knjige) | C++17 | 32 ms | 1068 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;
const int MAXN = 1000;
int n, p[MAXN];
stack <int> l, d;
vector <tuple <string, char, char> > potezi;
void potez(string a, char b, char c) {
potezi.push_back({a, b, c});
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> p[i];
}
for (int i = n - 1; i >= 0; i--) {
l.push(p[i]);
}
sort(p, p + n);
for (int i = 0; i < n; i++) {
int prebacio = 0;
while (l.top() != p[i]) {
potez("UZMI", 'L', 'L');
potez("STAVI", 'L', 'D');
d.push(l.top());
l.pop();
prebacio++;
}
potez("UZMI", 'D', 'L');
l.pop();
for (int j = 0; j < prebacio; j++) {
potez("UZMI", 'L', 'D');
potez("STAVI", 'L', 'L');
l.push(d.top());
d.pop();
}
potez("STAVI", 'D', 'D');
d.push(p[i]);
}
while (!d.empty()) {
potez("UZMI", 'L', 'D');
potez("STAVI", 'L', 'L');
l.push(d.top());
d.pop();
}
cout << potezi.size() << endl;
for (const auto &p : potezi) {
cout << get<0>(p) << ' ' << get<1>(p) << ' ' << get<2>(p) << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |