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