# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
366277 | model_code | Knjige (COCI20_knjige) | C++17 | 32 ms | 1068 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |