# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
844755 |
2023-09-05T19:48:27 Z |
vjudge1 |
Knjige (COCI20_knjige) |
C++17 |
|
3 ms |
1496 KB |
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 998244353;
const ll MAXN = 5005;
vector<int> A, srt;
string put(string hand, string shelf) {
return "STAVI " + hand + " " + shelf + "\n";
}
string take(string hand, string shelf) {
return "UZMI " + hand + " " + shelf + "\n";
}
int main() {
fast
int N;
cin >> N;
A = vector<int>(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
srt.push_back(A[i]);
}
sort(srt.begin(), srt.end());
stack<int> l, r;
vector<string> ans;
for (int i = N-1; i >= 0; i--)
l.push(A[i]);
while (l.size()) {
while (l.size() && srt.back() != l.top()) {
ans.push_back(take("L", "L"));
ans.push_back(put("L", "D"));
r.push(l.top());
l.pop();
}
ans.push_back(take("D", "L"));
l.pop();
while (l.size()) {
ans.push_back(take("L", "L"));
ans.push_back(put("L", "D"));
r.push(l.top());
l.pop();
}
ans.push_back(put("D", "L"));
while (r.size()) {
ans.push_back(take("L", "D"));
ans.push_back(put("L", "L"));
l.push(r.top());
r.pop();
}
srt.pop_back();
}
cout << ans.size() << "\n";
for (auto u : ans)
cout << u;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1492 KB |
Output is correct |
2 |
Correct |
2 ms |
1492 KB |
Output is correct |
3 |
Correct |
2 ms |
1496 KB |
Output is correct |
4 |
Correct |
2 ms |
1496 KB |
Output is correct |
5 |
Correct |
2 ms |
1496 KB |
Output is correct |
6 |
Correct |
3 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1492 KB |
Output is correct |
8 |
Correct |
2 ms |
1496 KB |
Output is correct |
9 |
Correct |
2 ms |
1496 KB |
Output is correct |
10 |
Correct |
2 ms |
1492 KB |
Output is correct |