# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
445510 | grt | Knjige (COCI20_knjige) | C++17 | 2 ms | 472 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 ST first
#define ND second
#define PB push_back
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
const int nax = 110;
int n, d[nax];
vector<tuple<bool,bool,bool>>moves;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> d[i];
}
int tp = 0;
int cnt = 0;
for(int step = 1; step <= n; ++step) {
cnt = 0;
vi ord;
int target = 1000000;
for(int i = tp; i < n; ++i) {
target = min(target, d[i]);
}
while(d[tp] != target) {
//cout << "UZMI L L\n";
ord.PB(d[tp]);
moves.PB({0,0,0});
moves.PB({1,0,1});
cnt++;
tp++;
}
moves.PB({0, 1, 0});
for(int i = 0; i < cnt; ++i) {
moves.PB({0, 0, 1});
moves.PB({1, 0, 0});
}
moves.PB({1, 1, 1});
tp -= (cnt - 1);
//reverse(ord.begin(), ord.end());
for(int i = tp; i < tp + cnt; ++i) {
d[i] = ord[i - tp];
}
}
for(int i = 0; i < n; ++i) {
moves.PB({0, 1, 1});
moves.PB({1, 1, 0});
}
cout << (int)moves.size() << "\n";
for(auto [x,y,z] : moves) {
if(x) cout << "STAVI ";
else cout << "UZMI ";
if(y) cout << "D ";
else cout << "L ";
if(z) cout << "D ";
else cout << "L ";
cout << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |